Skip to content

Commit

Permalink
chore(release): v1.0.0 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus authored Oct 28, 2024
1 parent 8b894ab commit 5d41806
Show file tree
Hide file tree
Showing 21 changed files with 1,347 additions and 339 deletions.
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Thanks for contributing! -->

## Description

<!--- Describe your changes in detail -->

## Related Issue

<!--- Link the relevant issue here -->

## Type of Change

<!---
Please look at the following checklist and put an `x` in all the boxes that
apply to ensure that your PR can be accepted quickly:
-->

- [ ]`feat` -- New feature (non-breaking change which adds functionality)
- [ ] 🛠️ `fix` -- Bug fix (non-breaking change which fixes an issue)
- [ ]`!` -- Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 🧹 `refactor` -- Code refactor
- [ ]`ci` -- Build configuration change
- [ ] 📝 `docs` -- Documentation
- [ ] 🧪 `test` -- Test
- [ ] 🗑️ `chore` -- Chore
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
# Changelog

All notable changes to this project will be documented in this file.

## [1.0.0] - 2024-10-28

### 🎉 First Stable Release 🚀

This release marks the first stable release of the `win32_clipboard` package,
offering a refined and feature-rich API for interacting with the Windows
Clipboard in Dart.

### 🔄 Breaking Changes

- **`Clipboard`**:
- **`getData`**: Now returns `ClipboardData?` instead of `String?`.
- **`setData`**: Now takes a `ClipboardData` instance as the only argument.
- **`registerFormat`**: Now returns `ClipboardFormat` instead of `int`.
- **`ClipboardFormat`**:
- `formatId` field renamed to `id`.
- `name`: The optional named parameter `name` is now a required positional
parameter and is no longer nullable.
- `text`: Constant renamed to `unicodeText`.

### ✨ New Features

- **Clipboard File List Support**:
- Added `Clipboard.getFileList()` to retrieve a list of files from the
clipboard.
- Added `Clipboard.setFileList()` to set a list of files on the clipboard.
- Added `Clipboard.hasFileList` getter to check if the clipboard contains file
list data.
- Added `ClipboardFormat.fileList` constant for identifying the file list
format.

- **Data Change Listeners**:
- Added `Clipboard.onDataChanged(ClipboardFormat format)` to listen for
changes in specific clipboard formats.
- Added `Clipboard.onFileListChanged` getter to listen for file list changes.
- Added `Clipboard.onTextChanged` getter to listen for text changes.

- **New Data Types**:
- Introduced `ClipboardData` as a base class for clipboard data.
- Added subclasses:
- `FileListData` for handling file lists.
- `PointerData` for handling pointer-based data.
- `UnicodeTextData` for handling Unicode text data.

### 🛠 Improvements

- Refined API to be more intuitive and consistent across all clipboard
operations.
- Optimized internal structure for better performance and reliability.

### 🚨 Dart SDK Requirement

- Bumped the minimum required Dart SDK version to `3.5.0`.

## 0.1.3

- Bump minimum required Dart SDK version to `3.4.0`
Expand All @@ -15,3 +73,5 @@
## 0.1.0

- Initial version.

[1.0.0]: https://github.com/halildurmus/win32_clipboard/compare/v0.1.3...v1.0.0
49 changes: 40 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,65 @@ This package builds on top of the Dart [win32] package, offering a high-level
Dart wrapper that avoids the need for users to understand FFI or write directly
to the Win32 API.

## Features

- **Text Operations**: Easily read and write text to the clipboard.
- **File List Operations**: Easily read and write file lists to the clipboard.
- **Format Inspection**: Check available formats on the clipboard.
- **Custom Formats**: Register custom clipboard formats.
- **Clipboard Change Notifications**: Monitor changes to the clipboard contents.
- **Clear Clipboard**: Clear the clipboard contents.

To learn more, see the [API Documentation][api_documentation_link].

## Usage

### Retrieve text from the clipboard
### Text operations

```dart
import 'package:win32_clipboard/win32_clipboard.dart';
void main() {
if (Clipboard.hasText) {
print('Clipboard text: ${Clipboard.getText()}');
if (Clipboard.setText('Hello, world!')) {
print('Retrieved text from clipboard: "${Clipboard.getText()}"');
}
}
```

### Write text to the clipboard
### File list operations

```dart
import 'package:win32_clipboard/win32_clipboard.dart';
void main() {
if (Clipboard.setText('Hello, world!')) {
print('Clipboard now contains: ${Clipboard.getText()}');
if (Clipboard.setFileList([r'c:\src\file1.dart', r'd:\file2.txt'])) {
print('Retrieved file list from clipboard: ${Clipboard.getFileList()}');
}
}
```

### Listen for clipboard text changes

```dart
import 'package:win32_clipboard/win32_clipboard.dart';
void main() async {
// Subscribe to the clipboard text change stream.
final subscription = Clipboard.onTextChanged.listen((text) {
print('Clipboard text changed: "$text"');
}, cancelOnError: true);
print('Monitoring clipboard text changes for 30 seconds...');
// Now, copy some text to the clipboard to see the changes.
// Stop monitoring after 30 seconds.
await Future.delayed(const Duration(seconds: 30), () async {
await subscription.cancel();
print('Stopped monitoring.');
});
}
```

### Retrieve a list of available clipboard formats

```dart
Expand All @@ -57,13 +90,11 @@ import 'package:win32_clipboard/win32_clipboard.dart';
void main() {
if (Clipboard.clear()) {
print('Clipboard contents cleared successfully.');
print('Clipboard contents cleared.');
}
}
```

To learn more, see the [API Documentation][api_documentation_link].

## Feature requests and bugs

Please file feature requests and bugs at the
Expand Down
84 changes: 84 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,85 @@
include: package:lints/recommended.yaml

linter:
rules:
- always_declare_return_types
- always_put_required_named_parameters_first
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_dynamic_calls
- avoid_escaping_inner_quotes
- avoid_final_parameters
- avoid_multiple_declarations_per_line
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_this
- avoid_setters_without_getters
- avoid_slow_async_io
- avoid_type_to_string
- avoid_types_on_closure_parameters
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- cascade_invocations
- cast_nullable_to_non_nullable
- close_sinks
- combinators_ordering
- comment_references
- deprecated_consistency
- deprecated_member_use_from_same_package
- directives_ordering
- discarded_futures
- flutter_style_todos
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- literal_only_boolean_expressions
- matching_super_parameters
- missing_code_block_language_in_doc_comment
- missing_whitespace_between_adjacent_strings
- no_literal_bool_comparisons
- no_runtimeType_toString
- no_self_assignments
- noop_primitive_operations
- omit_local_variable_types
# - omit_obvious_property_types
- one_member_abstracts
- only_throw_errors
- parameter_assignments
- prefer_asserts_in_initializer_lists
- prefer_asserts_with_message
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_in_for_each
- prefer_final_locals
- prefer_if_elements_to_conditional_expressions
- prefer_int_literals
- prefer_mixin
- prefer_null_aware_method_calls
- prefer_relative_imports
- prefer_single_quotes
- prefer_void_to_null
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
# - specify_nonobvious_property_types
- throw_in_finally
- unawaited_futures
- unintended_html_in_doc_comment
- unnecessary_await_in_return
- unnecessary_breaks
- unnecessary_lambdas
- unnecessary_library_directive
- unnecessary_library_name
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unreachable_from_main
- use_enums
- use_if_null_to_convert_nulls_to_bools
- use_is_even_rather_than_modulo
- use_named_constants
- use_raw_strings
- use_string_buffers
- use_to_and_as_if_applicable
36 changes: 25 additions & 11 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
import 'package:win32_clipboard/win32_clipboard.dart';

void main() {
print('Clipboard has ${Clipboard.numberOfFormats} format(s)');
for (final format in Clipboard.formats) {
print('- $format');
}
// Clear the clipboard initially.
if (Clipboard.clear()) print('Clipboard cleared.');

// Check if the clipboard is empty.
if (Clipboard.isEmpty) print('Clipboard is empty.');

print('Clipboard is ${Clipboard.isEmpty ? 'empty' : 'not empty'}.');
// Set text data to the clipboard.
const text = 'Hello, Clipboard!';
if (Clipboard.setText(text)) print('Text set to clipboard: "$text"');

// Check if the clipboard has text data (optional).
if (Clipboard.hasText) {
print('Clipboard text: ${Clipboard.getText()}');
print('Clipboard has text data.');
// Retrieve and print the text data from the clipboard.
final text = Clipboard.getText();
print('Retrieved text from clipboard: "$text"');
}

if (Clipboard.setText('Hello, world!')) {
print('Clipboard now contains: ${Clipboard.getText()}');
}
// Set file list data to the clipboard.
final files = [r'c:\src\file1.dart', r'd:\file2.txt'];
if (Clipboard.setFileList(files)) print('File list set to clipboard: $files');

if (Clipboard.clear()) {
print('Clipboard contents cleared successfully.');
// Check if the clipboard has a file list (optional).
if (Clipboard.hasFileList) {
print('Clipboard has file list data.');
// Retrieve and print the file list from the clipboard.
final fileList = Clipboard.getFileList();
print('Retrieved file list from clipboard: $fileList');
}

// Clear the clipboard.
if (Clipboard.clear()) print('Clipboard contents cleared.');
}
Loading

0 comments on commit 5d41806

Please sign in to comment.