mirror of
				https://github.com/SikongJueluo/cc-utils.git
				synced 2025-11-04 11:17:50 +08:00 
			
		
		
		
	fix signal ref
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -3,7 +3,7 @@ node_modules
 | 
			
		||||
event/
 | 
			
		||||
build/
 | 
			
		||||
reference/
 | 
			
		||||
src/*/*.md
 | 
			
		||||
src/**/*.md
 | 
			
		||||
 | 
			
		||||
QWEN.md
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
    pnpm
 | 
			
		||||
    craftos-pc
 | 
			
		||||
    qwen-code
 | 
			
		||||
    gemini-cli
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  # https://devenv.sh/languages/
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import { UIComponent } from "./UIComponent";
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { KeyEvent } from "../event";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import { UIComponent } from "./UIComponent";
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { KeyEvent, CharEvent } from "../event";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import { UIComponent } from "./UIComponent";
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { KeyEvent } from "../event";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
import { UIComponent } from "./UIComponent";
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { KeyEvent } from "../event";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Tab component that allows switching between different pages
 | 
			
		||||
 * Similar to QT's TabWidget, currently implementing horizontal tabs only
 | 
			
		||||
 */
 | 
			
		||||
export class TabWidget extends UIComponent {
 | 
			
		||||
export class TabBar extends UIComponent {
 | 
			
		||||
  // Tab data structure - simple array of tab names
 | 
			
		||||
  private tabs: string[];
 | 
			
		||||
  private currentIndex: number;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { KeyEvent, CharEvent, TimerEvent } from "../event";
 | 
			
		||||
import { UIObject } from "./UIObject";
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,13 @@
 | 
			
		||||
 * Provides input/output, option selection and keyboard event handling
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { Signal } from "./signal";
 | 
			
		||||
import { Signal } from "./Signal";
 | 
			
		||||
import { UIObject } from "./UIObject";
 | 
			
		||||
import { UIComponent } from "./UIComponent";
 | 
			
		||||
import { TextLabel } from "./TextLabel";
 | 
			
		||||
import { InputField } from "./InputField";
 | 
			
		||||
import { OptionSelector } from "./OptionSelector";
 | 
			
		||||
import { TabWidget } from "./TabWidget";
 | 
			
		||||
import { TabBar } from "./TabBar";
 | 
			
		||||
import { UIWindow } from "./UIWindow";
 | 
			
		||||
import { TUIApplication } from "./TUIApplication";
 | 
			
		||||
import { Button } from "./Button";
 | 
			
		||||
@@ -23,7 +23,7 @@ export {
 | 
			
		||||
  TextLabel,
 | 
			
		||||
  InputField,
 | 
			
		||||
  OptionSelector,
 | 
			
		||||
  TabWidget,
 | 
			
		||||
  TabBar,
 | 
			
		||||
  UIWindow,
 | 
			
		||||
  TUIApplication,
 | 
			
		||||
  Button,
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ import {
 | 
			
		||||
  TextLabel,
 | 
			
		||||
  InputField,
 | 
			
		||||
  OptionSelector,
 | 
			
		||||
  TabWidget,
 | 
			
		||||
  TabBar,
 | 
			
		||||
  Button,
 | 
			
		||||
} from "../lib/ccTUI";
 | 
			
		||||
 | 
			
		||||
@@ -46,11 +46,27 @@ const optionSelector = new OptionSelector(
 | 
			
		||||
const statusLabel = new TextLabel("LableStatus", 5, 11, "Status: Ready");
 | 
			
		||||
 | 
			
		||||
// Create a button
 | 
			
		||||
const button = new Button("ButtonSubmit", 5, 13, "Submit", colors.white, colors.blue);
 | 
			
		||||
const button = new Button(
 | 
			
		||||
  "ButtonSubmit",
 | 
			
		||||
  5,
 | 
			
		||||
  13,
 | 
			
		||||
  "Submit",
 | 
			
		||||
  colors.white,
 | 
			
		||||
  colors.blue,
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
// Create tab widget with sample tabs - using longer tab names for testing
 | 
			
		||||
const tabNames = ["Home", "Settings", "User Profile", "Messages", "About Us", "Documentation", "Advanced Settings", "Account Management"];
 | 
			
		||||
const tabWidget = new TabWidget("TabWidget", 5, 3, 50, tabNames, 0);
 | 
			
		||||
const tabNames = [
 | 
			
		||||
  "Home",
 | 
			
		||||
  "Settings",
 | 
			
		||||
  "User Profile",
 | 
			
		||||
  "Messages",
 | 
			
		||||
  "About Us",
 | 
			
		||||
  "Documentation",
 | 
			
		||||
  "Advanced Settings",
 | 
			
		||||
  "Account Management",
 | 
			
		||||
];
 | 
			
		||||
const tabBar = new TabBar("TabWidget", 5, 3, 50, tabNames, 0);
 | 
			
		||||
 | 
			
		||||
// Add components to the application
 | 
			
		||||
app.addComponent(title);
 | 
			
		||||
@@ -60,10 +76,10 @@ app.addComponent(optionLabel);
 | 
			
		||||
app.addComponent(optionSelector);
 | 
			
		||||
app.addComponent(statusLabel);
 | 
			
		||||
app.addComponent(button);
 | 
			
		||||
app.addComponent(tabWidget);
 | 
			
		||||
app.addComponent(tabBar);
 | 
			
		||||
 | 
			
		||||
// Set focus to the input field initially
 | 
			
		||||
app.getWindow().setFocusFor(tabWidget);
 | 
			
		||||
app.getWindow().setFocusFor(tabBar);
 | 
			
		||||
 | 
			
		||||
// Connect events
 | 
			
		||||
optionSelector.onSelectionChanged.connect((data) => {
 | 
			
		||||
@@ -80,7 +96,7 @@ inputField.onTextChanged.connect((value) => {
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tabWidget.onTabChanged.connect((data) => {
 | 
			
		||||
tabBar.onTabChanged.connect((data) => {
 | 
			
		||||
  statusLabel.setText(
 | 
			
		||||
    `Status: Tab changed to ${data?.name} (index: ${data?.index})`,
 | 
			
		||||
  );
 | 
			
		||||
@@ -89,7 +105,9 @@ tabWidget.onTabChanged.connect((data) => {
 | 
			
		||||
button.onClick.connect(() => {
 | 
			
		||||
  const inputValue = inputField.getValue();
 | 
			
		||||
  const selectedOption = optionSelector.getSelectedValue();
 | 
			
		||||
  statusLabel.setText(`Status: Submitted - Input: "${inputValue}", Option: "${selectedOption}"`);
 | 
			
		||||
  statusLabel.setText(
 | 
			
		||||
    `Status: Submitted - Input: "${inputValue}", Option: "${selectedOption}"`,
 | 
			
		||||
  );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// Run the application
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user