Term-Title-0.07/000755 000765 000024 00000000000 12103336550 013656 5ustar00davidstaff000000 000000 Term-Title-0.07/Changes000644 000765 000024 00000001712 12103336550 015152 0ustar00davidstaff000000 000000 Revision history for Term-Title 0.07 2013-02-02 20:29:07 America/New_York - Fix for MSWin32 broken in 0.04 (CHORNY) 0.06 2013-01-27 12:26:47 America/New_York - Fix missing import in SYNOPSIS (MELO) 0.05 2013-01-26 23:10:52 America/New_York - Make Win32::Console a prereq only on Win32 (again) 0.04 2013-01-26 15:59:42 America/New_York - Mention iTerm2.app support (MELO) - Support Windows builds that set $^O to lower-case mswin32 (MELO) - Extract core logic of set_titlebar() into _set() (MELO) - Add set_tab_title() (MELO) - Distribution management converted to Dist::Zilla 0.03 Wed Mar 19 09:48:44 EDT 2008 - Added: support for 'screen' terminals (RT#34236 from David Precious) 0.02 Sat Mar 15 07:48:08 EDT 2008 - Changed: tests requiring manual verification won't fail on a buffered newline; now requires "y" or "n" explictly 0.01 Sun Mar 9 18:23:03 2008 - initial release Term-Title-0.07/CONTRIBUTING000644 000765 000024 00000003254 12103336550 015514 0ustar00davidstaff000000 000000 CONTRIBUTING Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. The distribution is managed with Dist::Zilla. This means than many of the usual files you might expect are not in the repository, but are generated at release time (e.g. Makefile.PL). However, you can run tests directly using the 'prove' tool: $ prove -l $ prove -lv t/some_test_file.t For most distributions, 'prove' is entirely sufficent for you to test any patches you have. You may need to satisfy some dependencies. See the included META.json file for a list. If you install App::mymeta_requires from CPAN, it's easy to satisfy any that you are missing by piping the output to your favorite CPAN client: $ mymeta-requires | cpanm $ cpan `mymeta-requires` Likewise, much of the documentation Pod is generated at release time. Depending on the distribution, some documentation may be written in a Pod dialect called WikiDoc. (See Pod::WikiDoc on CPAN.) If you would like to submit a documentation edit, please limit yourself to the documentation you see. If you see typos or documentation issues in the generated docs, please email or open a bug ticket instead of patching. Dist::Zilla is a very powerful authoring tool, but requires a number of author-specific plugins. If you would like to use it for contributing, install it from CPAN, then run one of the following commands, depending on your CPAN client: $ cpan `dzil authordeps` $ dzil authordeps | cpanm Once installed, here are some dzil commands you might try: $ dzil build $ dzil test $ dzil xtest You can learn more about Dist::Zilla at http://dzil.org/ Term-Title-0.07/dist.ini000644 000765 000024 00000000460 12103336550 015322 0ustar00davidstaff000000 000000 name = Term-Title author = David Golden license = Apache_2_0 copyright_holder = David Golden copyright_year = 2008 [@DAGOLDEN] :version = 0.035 stopwords = titlebar stopwords = rxvt stopwords = iTerm [RemovePrereqs] remove = Win32::Console [OSPrereqs / MSWin32] Win32::Console = 0 Term-Title-0.07/lib/000755 000765 000024 00000000000 12103336550 014424 5ustar00davidstaff000000 000000 Term-Title-0.07/LICENSE000644 000765 000024 00000026354 12103336550 014675 0ustar00davidstaff000000 000000 This software is Copyright (c) 2008 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Term-Title-0.07/Makefile.PL000644 000765 000024 00000002256 12103336550 015635 0ustar00davidstaff000000 000000 use strict; use warnings; use 5.006; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Portable API to set the terminal titlebar", "AUTHOR" => "David Golden ", "BUILD_REQUIRES" => { "File::Find" => 0, "File::Temp" => 0, "Test::More" => 0 }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Term-Title", "EXE_FILES" => [], "LICENSE" => "apache", "NAME" => "Term::Title", "PREREQ_PM" => { "Exporter" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "0.07", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; if ( $^O eq 'MSWin32' ) { $WriteMakefileArgs{PREREQ_PM}{'Win32::Console'} = '0'; } WriteMakefile(%WriteMakefileArgs); Term-Title-0.07/MANIFEST000644 000765 000024 00000000477 12103336550 015017 0ustar00davidstaff000000 000000 CONTRIBUTING Changes LICENSE MANIFEST META.json META.yml Makefile.PL README Todo dist.ini lib/Term/Title.pm perlcritic.rc t/00-compile.t t/01-Term-Title.t xt/author/critic.t xt/author/pod-spell.t xt/release/distmeta.t xt/release/pod-coverage.t xt/release/pod-syntax.t xt/release/portability.t xt/release/test-version.t Term-Title-0.07/META.json000644 000765 000024 00000003534 12103336550 015304 0ustar00davidstaff000000 000000 { "abstract" : "Portable API to set the terminal titlebar", "author" : [ "David Golden " ], "dynamic_config" : 1, "generated_by" : "Dist::Zilla version 4.300029, CPAN::Meta::Converter version 2.120921", "license" : [ "apache_2_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Term-Title", "no_index" : { "directory" : [ "t", "xt", "examples", "corpus" ], "package" : [ "DB" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Exporter" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Find" : "0", "File::Temp" : "0", "Test::More" : "0" } } }, "provides" : { "Term::Title" : { "file" : "lib/Term/Title.pm", "version" : "0.07" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Term-Title@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Term-Title" }, "homepage" : "https://metacpan.org/release/Term-Title", "repository" : { "type" : "git", "url" : "git://github.com/dagolden/term-title.git", "web" : "https://github.com/dagolden/term-title" } }, "version" : "0.07" } Term-Title-0.07/META.yml000644 000765 000024 00000001550 12103336550 015130 0ustar00davidstaff000000 000000 --- abstract: 'Portable API to set the terminal titlebar' author: - 'David Golden ' build_requires: File::Find: 0 File::Temp: 0 Test::More: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 1 generated_by: 'Dist::Zilla version 4.300029, CPAN::Meta::Converter version 2.120921' license: apache meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Term-Title no_index: directory: - t - xt - examples - corpus package: - DB provides: Term::Title: file: lib/Term/Title.pm version: 0.07 requires: Exporter: 0 perl: 5.006 strict: 0 warnings: 0 resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Term-Title homepage: https://metacpan.org/release/Term-Title repository: git://github.com/dagolden/term-title.git version: 0.07 Term-Title-0.07/perlcritic.rc000644 000765 000024 00000000744 12103336550 016351 0ustar00davidstaff000000 000000 severity = 5 verbose = 8 [Variables::ProhibitPunctuationVars] allow = $@ $! # Turn these off [-BuiltinFunctions::ProhibitStringyEval] [-ControlStructures::ProhibitPostfixControls] [-ControlStructures::ProhibitUnlessBlocks] [-Documentation::RequirePodSections] [-InputOutput::ProhibitInteractiveTest] [-References::ProhibitDoubleSigils] [-RegularExpressions::RequireExtendedFormatting] [-InputOutput::ProhibitTwoArgOpen] # Turn this on [Lax::ProhibitStringyEval::ExceptForRequire] Term-Title-0.07/README000644 000765 000024 00000005055 12103336550 014543 0ustar00davidstaff000000 000000 NAME Term::Title - Portable API to set the terminal titlebar VERSION version 0.07 SYNOPSIS use Term::Title 'set_titlebar', 'set_tab_title'; set_titlebar("This goes into the title"); set_titlebar("Title", "And also print this to the terminal"); set_tab_title("This goes into the tab title"); set_tab_title("Tab Title", "And also print this to the terminal"); DESCRIPTION Term::Title provides an abstraction for setting the titlebar or the tab title across different types of terminals. For *nix terminals, it prints the appropriate escape sequences to set the terminal or tab title based on the value of $ENV{TERM}. On Windows, it uses Win32::Console to set the title directly. Currently, changing the titlebar is supported in these terminals: * xterm * rxvt * screen * iTerm2.app * Win32 console The terminals that support changing the tab title include: * iTerm2.app USAGE set_titlebar set_titlebar( $title, @optional_text ); Sets the titlebar to $title or clears the titlebar if $title is undefined. On terminals that require printing escape codes to the terminal, a newline character is also printed to the terminal. If @optional_text is given, it will be printed to the terminal prior to the newline. Thus, to keep terminal output cleaner, use "set_titlebar()" in place of a "print()" statement to set the titlebar and print at the same time. If the terminal is not supported, set_titlebar silently continues, printing @optional_text if any. set_tab_title set_tab_title( $title, @optional_text ); Has the exact same semantics as the "set_titlebar" but changes the tab title. SEE ALSO * Win32::Console * SUPPORT Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. git clone git://github.com/dagolden/term-title.git AUTHOR David Golden COPYRIGHT AND LICENSE This software is Copyright (c) 2008 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Term-Title-0.07/t/000755 000765 000024 00000000000 12103336550 014121 5ustar00davidstaff000000 000000 Term-Title-0.07/Todo000644 000765 000024 00000000656 12103336550 014515 0ustar00davidstaff000000 000000 # Todo # Copyright (c) 2008 by David Golden. All rights reserved. # Licensed under Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License was distributed with this file or you may obtain a # copy of the License from http://www.apache.org/licenses/LICENSE-2.0 - Write some code - Write some tests - Replace boilerplate docs with real documentation Term-Title-0.07/xt/000755 000765 000024 00000000000 12103336550 014311 5ustar00davidstaff000000 000000 Term-Title-0.07/xt/author/000755 000765 000024 00000000000 12103336550 015613 5ustar00davidstaff000000 000000 Term-Title-0.07/xt/release/000755 000765 000024 00000000000 12103336550 015731 5ustar00davidstaff000000 000000 Term-Title-0.07/xt/release/distmeta.t000644 000765 000024 00000000217 12103336550 017730 0ustar00davidstaff000000 000000 #!perl use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok(); Term-Title-0.07/xt/release/pod-coverage.t000644 000765 000024 00000000527 12103336550 020475 0ustar00davidstaff000000 000000 #!perl use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Term-Title-0.07/xt/release/pod-syntax.t000644 000765 000024 00000000212 12103336550 020217 0ustar00davidstaff000000 000000 #!perl use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Term-Title-0.07/xt/release/portability.t000644 000765 000024 00000000277 12103336550 020466 0ustar00davidstaff000000 000000 #!perl use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; options(test_one_dot => 0); run_tests(); Term-Title-0.07/xt/release/test-version.t000644 000765 000024 00000000643 12103336550 020563 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 0.002004 BEGIN { eval "use Test::Version; 1;" or die $@; } my @imports = ( 'version_all_ok' ); my $params = { is_strict => 0, has_version => 1, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; Term-Title-0.07/xt/author/critic.t000644 000765 000024 00000000435 12103336550 017257 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; all_critic_ok(); Term-Title-0.07/xt/author/pod-spell.t000644 000765 000024 00000000457 12103336550 017705 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.002005 eval "use Test::Spelling 0.12; use Pod::Wordlist::hanekomu; 1" or die $@; add_stopwords(); all_pod_files_spelling_ok('bin', 'lib'); __DATA__ titlebar rxvt iTerm David Golden lib Term Title Term-Title-0.07/t/00-compile.t000644 000765 000024 00000003077 12103336550 016162 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; use File::Find; use File::Temp qw{ tempdir }; my @modules; find( sub { return if $File::Find::name !~ /\.pm\z/; my $found = $File::Find::name; $found =~ s{^lib/}{}; $found =~ s{[/\\]}{::}g; $found =~ s/\.pm$//; # nothing to skip push @modules, $found; }, 'lib', ); sub _find_scripts { my $dir = shift @_; my @found_scripts = (); find( sub { return unless -f; my $found = $File::Find::name; # nothing to skip open my $FH, '<', $_ or do { note( "Unable to open $found in ( $! ), skipping" ); return; }; my $shebang = <$FH>; return unless $shebang =~ /^#!.*?\bperl\b\s*$/; push @found_scripts, $found; }, $dir, ); return @found_scripts; } my @scripts; do { push @scripts, _find_scripts($_) if -d $_ } for qw{ bin script scripts }; my $plan = scalar(@modules) + scalar(@scripts); $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); { # fake home for cpan-testers local $ENV{HOME} = tempdir( CLEANUP => 1 ); like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) for sort @modules; SKIP: { eval "use Test::Script 1.05; 1;"; skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; foreach my $file ( @scripts ) { my $script = $file; $script =~ s!.*/!!; script_compiles( $file, "$script script compiles" ); } } } Term-Title-0.07/t/01-Term-Title.t000644 000765 000024 00000005332 12103336550 016515 0ustar00davidstaff000000 000000 # 01-Term-Title.t # Copyright (c) 2008 by David Golden. All rights reserved. # Licensed under Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License was distributed with this file or you may obtain a # copy of the License from http://www.apache.org/licenses/LICENSE-2.0 use strict; use warnings; use Test::More; plan tests => 8; #--------------------------------------------------------------------------# # y_n #--------------------------------------------------------------------------# sub y_n { my ($prompt) = @_; my $answer; while (1) { print STDERR "# $prompt (y/n)?\n"; $answer = ; last if $answer =~ /^[yn]/i; print STDERR "# Please answer 'y' or 'n'\n"; } return $answer =~ /^y/i; } #--------------------------------------------------------------------------# # tests start here #--------------------------------------------------------------------------# require_ok( 'Term::Title' ); can_ok( 'Term::Title', 'set_titlebar', 'set_tab_title', '_is_supported', '_is_supported_tabs' ); Term::Title->import('set_titlebar', 'set_tab_title'); can_ok( 'main', 'set_titlebar' ); can_ok( 'main', 'set_tab_title' ); # reclaim STDOUT from Test::More local *STDOUT; open STDOUT, ">>&=0" or die "Couldn't reclaim STDOUT from Test::More"; diag "Term appears to be '$ENV{TERM}'"; SKIP: { skip "Automated testing not supported title bars", 2 if $ENV{AUTOMATED_TESTING}; skip "Term::Title (set term title) not supported on this terminal type", 2 unless Term::Title::_is_supported(); my $phrase = "Hello"; set_titlebar("[$phrase]","# Setting title to ", "'[$phrase]'"); print STDERR "\n# (y/n)\n"; my $y_n = y_n( "Do you see '[$phrase]' in the title bar of this window?" ); ok( $y_n, "Title set correctly" ); # clear set_titlebar(); $y_n = y_n( "Has the title bar been cleared?" ); ok( $y_n, "Title cleared correctly" ); set_titlebar('set_titlebar() works!'); } SKIP: { skip "Automated testing not supported for tab titles", 2 if $ENV{AUTOMATED_TESTING}; skip "Term::Title (set tab title) not supported on this terminal type", 2 unless Term::Title::_is_supported_tabs(); my $phrase = "Hello"; set_tab_title("[$phrase]","# Setting title to ", "'[$phrase]'"); print STDERR "\n# (y/n)\n"; my $y_n = y_n( "Do you see '[$phrase]' in the tab title of this window?" ); ok( $y_n, "Tab title set correctly" ); # clear set_tab_title(); $y_n = y_n( "Has the tab title been cleared?" ); ok( $y_n, "Tab title cleared correctly" ); set_tab_title('set_tab_title() works!'); } Term-Title-0.07/lib/Term/000755 000765 000024 00000000000 12103336550 015333 5ustar00davidstaff000000 000000 Term-Title-0.07/lib/Term/Title.pm000644 000765 000024 00000011276 12103336550 016761 0ustar00davidstaff000000 000000 package Term::Title; use strict; use warnings; # ABSTRACT: Portable API to set the terminal titlebar our $VERSION = '0.07'; # VERSION use Exporter; our @ISA = 'Exporter'; our @EXPORT_OK = qw/set_titlebar set_tab_title/; # encodings by terminal type -- except for mswin32 get matched as regex # against $ENV{TERM} # code ref gets title and text to print my %terminal = ( 'xterm|rxvt' => { pre => "\033]2;", post => "\007", }, 'screen' => { pre => "\ek", post => "\e\\", }, 'mswin32' => sub { my ($title, @optional) = @_; my $c = Win32::Console->new(); $c->Title($title); print STDOUT @optional, "\n"; }, ); my %terminal_tabs = ( 'iterm2' => { is_supported => sub { $ENV{TERM_PROGRAM} and $ENV{TERM_PROGRAM} eq 'iTerm.app' }, pre => "\033]1;", post => "\007", }, ); sub _set { my ($type_cb, $types, $title, @optional) = @_; $title = q{ } unless defined $title; my $type = $type_cb->(); if ( $type ) { if ( ref $types->{$type} eq 'CODE' ) { $types->{$type}->( $title, @optional ); } elsif (ref $types->{$type} eq 'HASH' ) { print STDOUT $types->{$type}{pre}, $title, $types->{$type}{post}, @optional, "\n"; } } elsif ( @optional ) { print STDOUT @optional, "\n"; } return; } sub set_titlebar { _set(\&_is_supported, \%terminal, @_) } sub set_tab_title { _set(\&_is_supported_tabs, \%terminal_tabs, @_) } sub _is_supported { if ( lc($^O) eq 'mswin32' ) { return 'mswin32' if eval { require Win32::Console }; } else { return unless $ENV{TERM}; for my $k ( keys %terminal ) { return $k if $ENV{TERM} =~ /^(?:$k)/; } } return; } sub _is_supported_tabs { for my $k (keys %terminal_tabs) { return $k if $terminal_tabs{$k}{is_supported}->(); } return; } 1; __END__ =pod =head1 NAME Term::Title - Portable API to set the terminal titlebar =head1 VERSION version 0.07 =head1 SYNOPSIS use Term::Title 'set_titlebar', 'set_tab_title'; set_titlebar("This goes into the title"); set_titlebar("Title", "And also print this to the terminal"); set_tab_title("This goes into the tab title"); set_tab_title("Tab Title", "And also print this to the terminal"); =head1 DESCRIPTION Term::Title provides an abstraction for setting the titlebar or the tab title across different types of terminals. For *nix terminals, it prints the appropriate escape sequences to set the terminal or tab title based on the value of C<$ENV{TERM}>. On Windows, it uses L to set the title directly. Currently, changing the titlebar is supported in these terminals: =over 4 =item * xterm =item * rxvt =item * screen =item * iTerm2.app =item * Win32 console =back The terminals that support changing the tab title include: =over 4 =item * iTerm2.app =back =head1 USAGE =head2 set_titlebar set_titlebar( $title, @optional_text ); Sets the titlebar to C<$title> or clears the titlebar if C<$title> is undefined. On terminals that require printing escape codes to the terminal, a newline character is also printed to the terminal. If C< @optional_text > is given, it will be printed to the terminal prior to the newline. Thus, to keep terminal output cleaner, use C in place of a C statement to set the titlebar and print at the same time. If the terminal is not supported, set_titlebar silently continues, printing C<@optional_text> if any. =head2 set_tab_title set_tab_title( $title, @optional_text ); Has the exact same semantics as the L but changes the tab title. =head1 SEE ALSO =over 4 =item * L =item * L =back =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at L. You will be notified automatically of any progress on your issue. =head2 Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. L git clone git://github.com/dagolden/term-title.git =head1 AUTHOR David Golden =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2008 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 =cut