NCURSES-Programming-HOWTO.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

NCURSES-Programming-HOWTO.Pdf NCURSES Programming HOWTO Pradeep Padala <[email protected]> v1.9, 2005−06−20 Revision History Revision 1.9 2005−06−20 Revised by: ppadala The license has been changed to the MIT−style license used by NCURSES. Note that the programs are also re−licensed under this. Revision 1.8 2005−06−17 Revised by: ppadala Lots of updates. Added references and perl examples. Changes to examples. Many grammatical and stylistic changes to the content. Changes to NCURSES history. Revision 1.7.1 2002−06−25 Revised by: ppadala Added a README file for building and instructions for building from source. Revision 1.7 2002−06−25 Revised by: ppadala Added "Other formats" section and made a lot of fancy changes to the programs. Inlining of programs is gone. Revision 1.6.1 2002−02−24 Revised by: ppadala Removed the old Changelog section, cleaned the makefiles Revision 1.6 2002−02−16 Revised by: ppadala Corrected a lot of spelling mistakes, added ACS variables section Revision 1.5 2002−01−05 Revised by: ppadala Changed structure to present proper TOC Revision 1.3.1 2001−07−26 Revised by: ppadala Corrected maintainers paragraph, Corrected stable release number Revision 1.3 2001−07−24 Revised by: ppadala Added copyright notices to main document (LDP license) and programs (GPL), Corrected printw_example. Revision 1.2 2001−06−05 Revised by: ppadala Incorporated ravi's changes. Mainly to introduction, menu, form, justforfun sections Revision 1.1 2001−05−22 Revised by: ppadala Added "a word about window" section, Added scanw_example. This document is intended to be an "All in One" guide for programming with ncurses and its sister libraries. We graduate from a simple "Hello World" program to more complex form manipulation. No prior experience in ncurses is assumed. Send comments to this address NCURSES Programming HOWTO Table of Contents 1. Introduction.....................................................................................................................................................1 1.1. What is NCURSES?.........................................................................................................................1 1.2. What we can do with NCURSES......................................................................................................1 1.3. Where to get it...................................................................................................................................2 1.4. Purpose/Scope of the document........................................................................................................2 1.5. About the Programs..........................................................................................................................2 1.6. Other Formats of the document........................................................................................................4 1.6.1. Readily available formats from tldp.org..................................................................................4 1.6.2. Building from source...............................................................................................................4 1.7. Credits...............................................................................................................................................5 1.8. Wish List...........................................................................................................................................5 1.9. Copyright..........................................................................................................................................5 2. Hello World !!!................................................................................................................................................7 2.1. Compiling With the NCURSES Library..........................................................................................7 2.2. Dissection..........................................................................................................................................7 2.2.1. About initscr().........................................................................................................................7 2.2.2. The mysterious refresh().........................................................................................................8 2.2.3. About endwin()........................................................................................................................8 3. The Gory Details.............................................................................................................................................9 4. Initialization...................................................................................................................................................10 4.1. Initialization functions....................................................................................................................10 4.2. raw() and cbreak()...........................................................................................................................10 4.3. echo() and noecho()........................................................................................................................10 4.4. keypad()..........................................................................................................................................10 4.5. halfdelay().......................................................................................................................................10 4.6. Miscellaneous Initialization functions............................................................................................11 4.7. An Example....................................................................................................................................11 5. A Word about Windows...............................................................................................................................12 6. Output functions...........................................................................................................................................13 6.1. addch() class of functions...............................................................................................................13 6.2. mvaddch(), waddch() and mvwaddch()..........................................................................................13 6.3. printw() class of functions..............................................................................................................14 6.3.1. printw() and mvprintw...........................................................................................................14 6.3.2. wprintw() and mvwprintw.....................................................................................................14 6.3.3. vwprintw().............................................................................................................................14 6.3.4. A Simple printw example......................................................................................................14 6.4. addstr() class of functions...............................................................................................................15 6.5. A word of caution...........................................................................................................................15 7. Input functions..............................................................................................................................................16 7.1. getch() class of functions................................................................................................................16 7.2. scanw() class of functions...............................................................................................................16 7.2.1. scanw() and mvscanw...........................................................................................................16 i NCURSES Programming HOWTO Table of Contents 7. Input functions 7.2.2. wscanw() and mvwscanw()...................................................................................................16 7.2.3. vwscanw().............................................................................................................................16 7.3. getstr() class of functions................................................................................................................16 7.4. Some examples...............................................................................................................................17 8. Attributes.......................................................................................................................................................18 8.1. The details.......................................................................................................................................19 8.2. attron() vs attrset()...........................................................................................................................19 8.3. attr_get()..........................................................................................................................................20 8.4. attr_ functions.................................................................................................................................20 8.5. wattr functions................................................................................................................................20 8.6. chgat() functions.............................................................................................................................20
Recommended publications
  • Administering Unidata on UNIX Platforms
    C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\ADMINUNIX\ADMINUNIXTITLE.fm March 5, 2010 1:34 pm Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta UniData Administering UniData on UNIX Platforms UDT-720-ADMU-1 C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\ADMINUNIX\ADMINUNIXTITLE.fm March 5, 2010 1:34 pm Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Notices Edition Publication date: July, 2008 Book number: UDT-720-ADMU-1 Product version: UniData 7.2 Copyright © Rocket Software, Inc. 1988-2010. All Rights Reserved. Trademarks The following trademarks appear in this publication: Trademark Trademark Owner Rocket Software™ Rocket Software, Inc. Dynamic Connect® Rocket Software, Inc. RedBack® Rocket Software, Inc. SystemBuilder™ Rocket Software, Inc. UniData® Rocket Software, Inc. UniVerse™ Rocket Software, Inc. U2™ Rocket Software, Inc. U2.NET™ Rocket Software, Inc. U2 Web Development Environment™ Rocket Software, Inc. wIntegrate® Rocket Software, Inc. Microsoft® .NET Microsoft Corporation Microsoft® Office Excel®, Outlook®, Word Microsoft Corporation Windows® Microsoft Corporation Windows® 7 Microsoft Corporation Windows Vista® Microsoft Corporation Java™ and all Java-based trademarks and logos Sun Microsystems, Inc. UNIX® X/Open Company Limited ii SB/XA Getting Started The above trademarks are property of the specified companies in the United States, other countries, or both. All other products or services mentioned in this document may be covered by the trademarks, service marks, or product names as designated by the companies who own or market them. License agreement This software and the associated documentation are proprietary and confidential to Rocket Software, Inc., are furnished under license, and may be used and copied only in accordance with the terms of such license and with the inclusion of the copyright notice.
    [Show full text]
  • Technical Standard
    Technical Standard X/Open Curses, Issue 7 The Open Group ©November 2009, The Open Group All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior permission of the copyright owners. Technical Standard X/Open Curses, Issue 7 ISBN: 1-931624-83-6 Document Number: C094 Published in the U.K. by The Open Group, November 2009. This standardhas been prepared by The Open Group Base Working Group. Feedback relating to the material contained within this standardmay be submitted by using the web site at http://austingroupbugs.net with the Project field set to "Xcurses Issue 7". ii Technical Standard 2009 Contents Chapter 1 Introduction........................................................................................... 1 1.1 This Document ........................................................................................ 1 1.1.1 Relationship to Previous Issues ......................................................... 1 1.1.2 Features Introduced in Issue 7 ........................................................... 2 1.1.3 Features Withdrawn in Issue 7........................................................... 2 1.1.4 Features Introduced in Issue 4 ........................................................... 2 1.2 Conformance............................................................................................ 3 1.2.1 Base Curses Conformance .................................................................
    [Show full text]
  • Gpsbabel Documentation Gpsbabel Documentation Table of Contents
    GPSBabel Documentation GPSBabel Documentation Table of Contents Introduction to GPSBabel ................................................................................................... xx The Problem: Too many incompatible GPS file formats ................................................... xx The Solution ............................................................................................................ xx 1. Getting or Building GPSBabel .......................................................................................... 1 Downloading - the easy way. ....................................................................................... 1 Building from source. .................................................................................................. 1 2. Usage ........................................................................................................................... 3 Invocation ................................................................................................................. 3 Suboptions ................................................................................................................ 4 Advanced Usage ........................................................................................................ 4 Route and Track Modes .............................................................................................. 5 Working with predefined options .................................................................................. 6 Realtime tracking ......................................................................................................
    [Show full text]
  • Porting a Window Manager from Xlib to XCB
    Porting a Window Manager from Xlib to XCB Arnaud Fontaine (08090091) 16 May 2008 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version pub- lished by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Contents List of figures i List of listings ii Introduction 1 1 Backgrounds and Motivations 2 2 X Window System (X11) 6 2.1 Introduction . .6 2.2 History . .6 2.3 X Window Protocol . .7 2.3.1 Introduction . .7 2.3.2 Protocol overview . .8 2.3.3 Identifiers of resources . 10 2.3.4 Atoms . 10 2.3.5 Windows . 12 2.3.6 Pixmaps . 14 2.3.7 Events . 14 2.3.8 Keyboard and pointer . 15 2.3.9 Extensions . 17 2.4 X protocol client libraries . 18 2.4.1 Xlib . 18 2.4.1.1 Introduction . 18 2.4.1.2 Data types and functions . 18 2.4.1.3 Pros . 19 2.4.1.4 Cons . 19 2.4.1.5 Example . 20 2.4.2 XCB . 20 2.4.2.1 Introduction . 20 2.4.2.2 Data types and functions . 21 2.4.2.3 xcb-util library . 22 2.4.2.4 Pros . 22 2.4.2.5 Cons . 23 2.4.2.6 Example . 23 2.4.3 Xlib/XCB round-trip performance comparison .
    [Show full text]
  • Version 7.8-Systemd
    Linux From Scratch Version 7.8-systemd Created by Gerard Beekmans Edited by Douglas R. Reno Linux From Scratch: Version 7.8-systemd by Created by Gerard Beekmans and Edited by Douglas R. Reno Copyright © 1999-2015 Gerard Beekmans Copyright © 1999-2015, Gerard Beekmans All rights reserved. This book is licensed under a Creative Commons License. Computer instructions may be extracted from the book under the MIT License. Linux® is a registered trademark of Linus Torvalds. Linux From Scratch - Version 7.8-systemd Table of Contents Preface .......................................................................................................................................................................... vii i. Foreword ............................................................................................................................................................. vii ii. Audience ............................................................................................................................................................ vii iii. LFS Target Architectures ................................................................................................................................ viii iv. LFS and Standards ............................................................................................................................................ ix v. Rationale for Packages in the Book .................................................................................................................... x vi. Prerequisites
    [Show full text]
  • CONNX Installation Guide Version 11.5
    CONNX Installation Guide Version 11.5 Table Of Contents Preface .......................................................................................................................................................... 1 About the Installation Guide .......................................................................................................................... 1 Database Terminology .................................................................................................................................. 2 Installation Overview ..................................................................................................................................... 3 CONNX Installation Checklist ....................................................................................................................... 4 Upgrade Installation Checklist ...................................................................................................................... 5 Displaying Your CONNX Version .................................................................................................................. 6 To display the CONNX version and build numbers ............................................................................... 6 How CONNX Works ...................................................................................................................................... 7 Related Topics ......................................................................................................................................
    [Show full text]
  • Use of Third Party Libraries Docker Postgres-9.6.6
    Docker postgres-9.6.6 - Use of Third Party Libraries Name Selected License libc-utils 0.7 (BSD) BSD-Style License libedit 20150325.3.1 (BSD) BSD-Style License libuuid 2.28.2 (BSD-3) BSD-Style License readline 6.3 (GPL) GNU General Public License alpine-baselayout 3.0.4 (GPL v2) GNU General Public License v2.0 apk-tools 2.6.9 (GPL v2) GNU General Public License v2.0 busybox 1.25.1 (GPL v2) GNU General Public License v2.0 scanelf 1.1.6 (GPL2) GNU General Public License v2.0 bash 4.3.46 (GPL v3) GNU General Public License v3.0 or later libgcrypt 1.7.9 (LGPL v2.1) GNU Library General Public License v2.0 or later libgpg-error 1.24 (LGPL v2.1) GNU Library General Public License v2.0 or later alpine-keys 1.3-r0 (MIT) MIT License (also X11) libxml2 2.9.4 (MIT) MIT License (also X11) libxslt 1.1.29 (MIT) MIT License (also X11) su-exec 0.2 (MIT) MIT License (also X11) musl 1.1.15 (MIT) MIT-Style License musl-utils 1.1.15 (MIT) MIT-Style License ncurses-libs 6.0 (MIT) MIT-Style License libcrypto1.0 1.0.2m (openssl) OpenSSL License libressl2.4-libcrypto 2.4.4 (OpenSSL) OpenSSL License libressl2.4-libssl 2.4.4 (OpenSSL) OpenSSL License libssl1.0 1.0.2m (OpenSSL) OpenSSL License tzdata 2016i (Public Domain) Public Domain postgres-9.6.6-alpine-3.5.2 (PostgreSQL) The PostgreSQL License ncurses-terminfo 6.0 (MIT) X11 License ncurses-terminfo-base 6.0 (MIT) X11 License zlib 1.2.11 (zlib) zlib License Docker postgres-9.6.6 - Third-Party Notices Report [alpine-baselayout 3.0.4 (GPL v2)] Copyright Statements TOC 1.3.1 1 License Agreements Recipients who would like to receive a copy of such source code should submit a request to Tripwire by email, at [email protected].
    [Show full text]
  • UG1144 (V2020.1) July 24, 2020 Revision History
    See all versions of this document PetaLinux Tools Documentation Reference Guide UG1144 (v2020.1) July 24, 2020 Revision History Revision History The following table shows the revision history for this document. Section Revision Summary 07/24/2020 Version 2020.1 Appendix H: Partitioning and Formatting an SD Card Added a new appendix. 06/03/2020 Version 2020.1 Chapter 2: Setting Up Your Environment Added the Installing a Preferred eSDK as part of the PetaLinux Tool section. Chapter 4: Configuring and Building Added the PetaLinux Commands with Equivalent devtool Commands section. Chapter 6: Upgrading the Workspace Added new sections: petalinux-upgrade Options, Upgrading Between Minor Releases (2020.1 Tool with 2020.2 Tool) , Upgrading the Installed Tool with More Platforms, and Upgrading the Installed Tool with your Customized Platform. Chapter 7: Customizing the Project Added new sections: Creating Partitioned Images Using Wic and Configuring SD Card ext File System Boot. Chapter 8: Customizing the Root File System Added the Appending Root File System Packages section. Chapter 10: Advanced Configurations Updated PetaLinux Menuconfig System. Chapter 11: Yocto Features Added the Adding Extra Users to the PetaLinux System section. Appendix A: Migration Added Tool/Project Directory Structure. UG1144 (v2020.1) July 24, 2020Send Feedback www.xilinx.com PetaLinux Tools Documentation Reference Guide 2 Table of Contents Revision History...............................................................................................................2
    [Show full text]
  • C/C++ Compile Guide
    WizFi630S Guide C/C++ Compile Guide (Version 1.0.0) © 2019 WIZnet Co., Ltd. All Rights Reserved. For more information, please visit our website at http://www.wiznet.io/ © Copyright 2019 WIZnet Co., Ltd. All rights reserved. 1 WizFi630S Guide Document Revision History Date Revision Changes 2019-11-25 1.0 Release © Copyright 2019 WIZnet Co., Ltd. All rights reserved. 2 WizFi630S Guide Contents 1. Overview ................................................................................................................. 4 2. Download ................................................................................................................ 4 2.1 Prerequisites .................................................................................................. 4 2.2 Packages for Building Environment .......................................................... 4 2.3 OpenWRT Firmware Repository................................................................. 6 2.4 Menuconfig .................................................................................................... 7 3. Write C Code........................................................................................................... 7 3.1 Helloworld ...................................................................................................... 7 3.2 Make the Environment Script .................................................................... 8 4. Cross Compile ......................................................................................................... 8 4.1
    [Show full text]
  • Real World Instrumentation with Python" # by J
    CHAPTER 13 User Interfaces 7KH3ULQFLSOHRI/HDVW$VWRQLVKPHQW0DNHDXVHU LQWHUIDFHDVFRQVLVWHQWDQGDVSUHGLFWDEOHDVSRVVLEOH ¢$QRQ\PRXV 8QOHVVDQDSSOLFDWLRQLVGHHSO\HPEHGGHGRUVSHFLILFDOO\GHVLJQHGWRUXQDVDEDFN JURXQGSURFHVVLWZLOOSUREDEO\QHHGVRPHW\SHRIXVHULQWHUIDFH,QWKLVFKDSWHUZH ZLOOH[SORUHGLI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JHU LVDFWLYHWKHZKROHVFUHHQLVWKHFRQVROHEXWLWEHKDYHVMXVWOLNHWKHZLQGRZHGIRUP 487 6HQGLQJGDWDWRWKHVKHOOLQWKHIRUPRIVWULQJVLVHDV\¢WKDW¦VZKDWWKHprintVWDWHPHQW GRHV*HWWLQJLQSXWEDFNIURPDXVHULVQRWDVLQWXLWLYHO\REYLRXVPDLQO\EHFDXVH3\
    [Show full text]
  • C++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield
    C++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield Publisher: Prentice Hall Pub Date: February 04, 2008 Print ISBN-10: 0-13-235416-0 Print ISBN-13: 978-0-13-235416-5 eText ISBN-10: 0-13-714397-4 eText ISBN-13: 978-0-13-714397-9 Pages: 752 Table of Contents | Index Overview The Only Official, Best-Practice Guide to Qt 4.3 Programming Using Trolltech's Qt you can build industrial-strength C++ applications that run natively on Windows, Linux/Unix, Mac OS X, and embedded Linux without source code changes. Now, two Trolltech insiders have written a start-to-finish guide to getting outstanding results with the latest version of Qt: Qt 4.3. Packed with realistic examples and in-depth advice, this is the book Trolltech uses to teach Qt to its own new hires. Extensively revised and expanded, it reveals today's best Qt programming patterns for everything from implementing model/view architecture to using Qt 4.3's improved graphics support. You'll find proven solutions for virtually every GUI development task, as well as sophisticated techniques for providing database access, integrating XML, using subclassing, composition, and more. Whether you're new to Qt or upgrading from an older version, this book can help you accomplish everything that Qt 4.3 makes possible. • Completely updated throughout, with significant new coverage of databases, XML, and Qtopia embedded programming • Covers all Qt 4.2/4.3 changes, including Windows Vista support, native CSS support for widget styling, and SVG file generation • Contains
    [Show full text]
  • Enterprise Peopletools 8.50 Peoplebook: System and Server Administration
    Enterprise PeopleTools 8.50 PeopleBook: System and Server Administration September 2009 Enterprise PeopleTools 8.50 PeopleBook: System and Server Administration SKU pt850pbr0 Copyright © 1988, 2009, Oracle and/or its affiliates. All rights reserved. Trademark Notice Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. License Restrictions Warranty/Consequential Damages Disclaimer This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. Warranty Disclaimer The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. Restricted Rights Notice If this software or related documentation is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007).
    [Show full text]