CN113220288A - Swing-based interactive system command line tool and software - Google Patents

Swing-based interactive system command line tool and software Download PDF

Info

Publication number
CN113220288A
CN113220288A CN202110577958.7A CN202110577958A CN113220288A CN 113220288 A CN113220288 A CN 113220288A CN 202110577958 A CN202110577958 A CN 202110577958A CN 113220288 A CN113220288 A CN 113220288A
Authority
CN
China
Prior art keywords
characters
character
command
output
swing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110577958.7A
Other languages
Chinese (zh)
Inventor
张元超
冯路
杨国卿
苗健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Highgo Base Software Co ltd
Original Assignee
Highgo Base Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Highgo Base Software Co ltd filed Critical Highgo Base Software Co ltd
Priority to CN202110577958.7A priority Critical patent/CN113220288A/en
Publication of CN113220288A publication Critical patent/CN113220288A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention discloses an interactive system command line tool and software based on swing. An interactive system command line tool based on swing, comprising: the processing unit is used for acquiring command characters input by a user, sending the command characters to an operating system, receiving output characters fed back by the operating system and sending the output characters to the display unit; and the display unit is used for displaying the output characters on an interface based on the swing component. The interactive system command line tool based on swing can be integrated into software, such as graphical operation software developed by java, when a user inputs a command of an operating system, the user does not need to quit the running of the software, and the command line tool of the operating system is independently opened, so that the user can directly operate in the software, the functions of the software are expanded, and the use of the user is greatly facilitated. The tool may also be run on multiple platforms, e.g., x86, arm series platforms, loongson, etc.

Description

Swing-based interactive system command line tool and software
Technical Field
The invention relates to the technical field of computers, in particular to a swing-based interactive system command line tool and software.
Background
At present, command line tools (such as CMD of windows and Terminal of linux) of each operating system can only run independently in the operating system and cannot be embedded into developed software, which brings great problems to function implementation and usability of the software, is also not beneficial to operation of a user, and the user needs to constantly switch the command line tools and the software of the operating system, so that the user experience is poor.
Disclosure of Invention
The embodiment of the invention provides an interactive system command line tool and software based on swing, which are used for solving the problem that the command line tool of an operating system can not be embedded into developed software in the prior art.
The interactive system command line tool based on swing comprises the following components:
the processing unit is used for acquiring command characters input by a user, sending the command characters to an operating system, receiving output characters fed back by the operating system and sending the output characters to the display unit;
and the display unit is used for displaying the output characters on an interface based on the swing component.
According to some embodiments of the invention, the processing unit comprises:
the input processor is used for monitoring the command characters, processing the command characters and then sending the processed command characters to the operating system;
and the output processor is used for receiving the output characters fed back by the operating system, processing the output characters and then sending the processed output characters to the display unit.
According to some embodiments of the invention, the input processor is configured to:
judging the type of the command character;
when the command character is a text character, directly sending the command character to the operating system in a byte mode;
and when the command character is a control character, encoding the command character and sending the encoded command character to the operating system.
According to some embodiments of the invention, the output processor is configured to:
judging the type of the output character;
when the output character is a text character, directly sending the output character to the display unit in a byte mode;
and when the output character is a control character, decoding the output character and sending the decoded output character to the display unit.
According to some embodiments of the invention, the display unit is configured to:
and displaying the processed output character on an interface based on the swing component.
According to some embodiments of the invention, the control character of the command character comprises at least one of the following characters: carriage return characters, tabulation characters, deletion characters, space characters, upper key characters, lower key characters, left key characters and right key characters.
According to some embodiments of the invention, the control character of the output character comprises a cursor.
According to some embodiments of the invention, the states of the cursor include a first state, a second state, and a third state;
the display unit is used for:
when the interface is selected, refreshing the interface to enable the cursor to be alternately presented between a first state and a second state;
when the interface is not selected, the cursor keeps a third state;
storing historical text characters;
and acquiring and displaying the historical text characters and the latest text characters with the corresponding number according to the size of the current interface.
According to some embodiments of the invention, the processing unit interacts with the operating system through a virtual terminal PTY.
According to the software of the embodiment of the invention, the software is integrated with the swing-based interactive system command line tool.
By adopting the embodiment of the invention, the operation interface of the operating system command is realized by swing, and the interactive system command can be executed, so that the operating system command line operation can be integrated into java graphical software, and cross-platform operation can be realized, comprising the following steps: x86, arm series platform, Loongson.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. In the drawings:
FIG. 1 is a schematic structural diagram of a swing-based interactive system command line tool in an embodiment of the present invention;
fig. 2 is a schematic diagram of a text character storage structure in the embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Some software (e.g., xshell) that implements the remote connection linux can also execute commands of the local operating system. However, only simple system commands can be executed, and the execution of interactive system commands (such as sql commands like oracle, psql commands like postgresql, and mysql commands like mysql) cannot be completed) is greatly limited in use. Moreover, the method needs to be operated independently, cannot be embedded into other software for use, is not developed in java language, and cannot be integrated in java graphical software.
Based on this, an embodiment of the first aspect of the present invention provides a swing-based interactive system command line tool, including:
the processing unit is used for acquiring command characters input by a user, sending the command characters to the operating system, receiving output characters fed back by the operating system and sending the output characters to the display unit;
and the display unit is used for displaying the output characters on the interface based on the swing component, in other words, displaying the output characters in the form of the interface.
The interactive system command line tool based on swing can be integrated into software, such as graphical operating software developed by java, when a user inputs a command of an operating system, the user does not need to quit the running of the software, and the command line tool of the operating system is independently opened, so that the user can directly operate in the software, the functions of the software are expanded, and the use of the user is greatly facilitated. The tool may also be run on multiple platforms, e.g., x86, arm series platforms, loongson, etc.
On the basis of the above-described embodiment, various modified embodiments are further proposed, and it is to be noted herein that, in order to make the description brief, only the differences from the above-described embodiment are described in the various modified embodiments.
According to some embodiments of the invention, a processing unit comprises:
the input processor is used for monitoring command characters, processing the command characters and then sending the processed command characters to the operating system; for example, the command characters input by the user are obtained by monitoring the input operation of the keyboard.
And the output processor is used for receiving the output characters fed back by the operating system, processing the output characters and then sending the processed output characters to the display unit.
According to some embodiments of the invention, the input processor is to:
judging the type of the command character;
when the command character is a text character, directly sending the command character to an operating system in a byte mode;
and when the command character is a control character, encoding the command character and sending the encoded command character to an operating system.
According to some embodiments of the invention, the output processor is to:
judging the type of the output character;
when the output character is a text character, directly sending the output character to a display unit in a byte mode;
and when the output character is the control character, decoding the output character and sending the decoded output character to the display unit.
According to some embodiments of the invention, a display unit is configured to:
and displaying the processed output characters on the interface based on the swing component, in other words, displaying the processed output characters in the form of the interface. The interface is provided by a panel in the swing component and can be used integrally.
According to some embodiments of the invention, the control character of the command character comprises at least one of the following characters: carriage return characters, tabulation characters, deletion characters, space characters, upper key characters, lower key characters, left key characters and right key characters.
According to some embodiments of the invention, the control character of the output character comprises a cursor. If 1A appears in the control character, the cursor needs to be moved up by one line for display.
According to some embodiments of the invention, the states of the cursor include a first state, a second state, and a third state;
a display unit for:
when the interface is selected, the cursor is alternately presented between a first state and a second state by refreshing the interface;
when the interface is not selected, the cursor keeps a third state;
storing historical text characters;
and acquiring and displaying the historical text characters and the latest text characters with the corresponding number according to the size of the current interface.
For example, when the display unit displays the cursor state, because the cursor needs to flash, the interface needs to be refreshed and redrawn continuously, and the precondition for redrawing the interface is that the current interface is selected. The cursor has three states, respectively: colored filled rectangles (first state), hidden (second state) and framed or unfilled (third state). When the interface is selected, the cursor state is alternately presented in a first state and a second state, the alternate presentation of the cursor is realized by refreshing the whole interface, and the state of the cursor is required to be changed and the character content is required to be reprinted when the interface is refreshed; when the interface is not selected, the cursor state is the third state, and the interface is not redrawn at the moment.
When the display unit displays the character content, the characters on the interface need to be stored because the interface needs to be redrawn continuously, and the characters are prevented from being lost during redrawing. The interface character content is divided into two parts: the latest character content and the historical character content. The latest character content refers to the latest character required to be displayed on the interface; the historical character content is displayed, characters which cannot be printed on the current interface are displayed, and the historical characters are displayed mainly when the interface is scrolled. The latest character content or the historical character content is stored according to a certain data structure. Fig. 2 is a schematic diagram of a storage structure of text characters, and it is to be noted here that the storage structure of character contents respectively has two lists, namely a horizontal list and a vertical list, the horizontal list stores the character contents of each line, and the vertical list stores all line objects.
Note that the drawing of the interface includes printing of a cursor and printing of characters, and the cursor printing mainly alternates states every refresh, and it should be noted here that the cursor position changes depending on the content of the drawing. The basic unit of character printing is a single character, a character object list needing to be printed is recalculated according to the size of the current interface before the interface is drawn each time, in the drawing process, each character row object in the list is traversed, each character in each character row object is traversed for drawing, and the current cursor position needs to be continuously updated during drawing so as to facilitate the drawing of a cursor.
According to some embodiments of the invention, the processing unit interacts with the operating system through a virtual terminal PTY.
If the command character is a text character, the input processor will send the text character directly to the PTY in bytes; if the command character is a control character, the input processor will perform preliminary processing on the command character, which mainly includes encoding the command character, and then send the processed command character to the PTY.
And after receiving the processed command characters sent by the input processor, the PTY transfers the command characters to the operating system for processing, and sends the processing result of the operating system to the output processor.
The PTY may be provided by the operating system and the specific meaning of the entered command characters in the operating system is done by the PTY.
The swen-based interactable system command line tool according to embodiments of the present invention is described in detail in one specific embodiment with reference to fig. 1-2. It is to be understood that the following description is illustrative only and is not intended to be in any way limiting. All similar structures and similar variations thereof adopted by the invention are intended to fall within the scope of the invention.
As shown in FIG. 1, the swing-based interactive system command line tool of the embodiment of the present invention comprises an input processor, an output processor, and a display unit (i.e., the interface shown in the figure).
The input processor is used for creating a monitor to monitor the input operation of the keyboard, and whether the input command character is a text character or a control character is judged in the input processor. If the character is a text character, the character is directly sent to the PTY in a byte mode; if the control character is the control character, the input processor needs to perform preliminary processing, mainly encode the command character, and then send the processed command character to the PTY.
The PTY is used for receiving the command characters sent by the input processor, transferring the command characters to an operating system for processing, and then sending the processing result to the output processor.
The output processor is used for receiving the output character returned by the PTY. There are two types of output characters, text characters and control characters. If the received characters are common text characters, directly delivering the characters to an interface of a display unit for printing; if the received control character is the control character, the control character needs to be analyzed, and then corresponding operation is carried out according to the result.
It should be noted here that it is necessary to distinguish between control characters in the input processor and control characters in the output processor, where the control characters represent different meanings in different processors. In the input manager, the control characters are non-displayable characters such as enter, tab, delete, space, up, down, left, right, and the like. In the output manager, the control character is a character for controlling printing behavior, and is mainly used for controlling the position of a cursor in an interface (the cursor represents the starting position of the next character printing and is displayed in a flashing manner), and if 1A appears in the control character, the cursor needs to be moved upwards by one line for display.
The display unit is responsible for printing the output characters to be displayed, and the characters seen on the interface are not directly input by the keyboard but are controlled by the output processor.
The interface printing mainly comprises two parts, namely character content and a cursor, and the printing principle of the interface is explained in detail below.
1. Cursor state:
because the cursor needs the effect of flickering, the interface needs to be refreshed and redrawn continuously, and the precondition for redrawing the interface is that the current interface is selected. The cursor has three states, respectively: colored filled rectangles (first state), hidden (second state) and framed or unfilled (third state). When the interface is selected, the cursor state is alternately presented in a first state and a second state, the alternate presentation of the cursor is realized by refreshing the whole interface, and the state of the cursor is required to be changed and the character content is required to be reprinted when the interface is refreshed; when the interface is not selected, the cursor state is the third state, and the interface is not redrawn at the moment.
2. The character content structure is as follows:
because the interface needs to be redrawn continuously, the characters on the interface need to be stored, and are prevented from being lost during redrawing. The interface character content is divided into two parts: the latest character content and the historical character content. The latest character content refers to the latest character required to be displayed on the interface; the historical character content is displayed, characters which cannot be printed on the current interface are displayed, and the historical characters are displayed mainly when the interface is scrolled. The latest character content or the historical character content is stored according to a certain data structure. Fig. 2 is a schematic diagram of a storage structure of text characters, and as shown in fig. 2, the storage structure of character contents respectively includes two lists, namely a horizontal list and a vertical list, the horizontal list stores the character contents of each line, and the vertical list stores all line objects.
3. Drawing an interface:
the drawing of the interface includes the printing of the cursor and the printing of the characters, the cursor printing mainly alternates states every time the refresh is performed, which is described in detail in 1, and it should be noted that the cursor position may change according to the content of the drawing. The basic unit of character printing is a single character, a character object list needing to be printed is recalculated according to the size of the current interface before the interface is drawn each time, in the drawing process, each character row object in the list is traversed, each character in each character row object is traversed for drawing, and the current cursor position needs to be continuously updated during drawing so as to facilitate the drawing of a cursor.
The embodiment of the invention can really realize the execution of the command line of the operating system, because the PTY mechanism based on the operating system can run all commands in the operating system, and the commands can be interactive or non-interactive. The method can be integrated into graphical software developed based on java, can be independently operated, can also be embedded into other graphical software developed based on java for use, meets most of use requirements, is realized based on linux bottom layer PTY, is developed by using java, is independent of a platform architecture, and has a wide use range.
It should be noted that the above-mentioned embodiments are only preferred embodiments of the present invention, and are not intended to limit the present invention, and those skilled in the art can make various modifications and changes. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
An embodiment of a second aspect of the present invention provides software that integrates a swing-based interactive system command line tool as described in the embodiment of the first aspect.
According to the software of the embodiment of the invention, by integrating the swing-based interactive system command line tool, when a user inputs a command of an operating system, the user can directly operate in the software without quitting the operation of the software and independently opening the command line tool of the operating system, so that the functions of the software are expanded, and the use by the user is greatly facilitated.
According to some embodiments of the invention, the software may be graphical operating software developed by java.
It should be noted that, in the description of the present specification, suffixes such as "module", "component", or "unit" used to indicate elements are used only for facilitating the description of the present invention, and have no specific meaning in itself. Thus, "module", "component" or "unit" may be used mixedly.
The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Furthermore, any reference signs placed between parentheses shall not be construed as limiting the claim. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.

Claims (10)

1. A swing-based interactable system command line tool, comprising:
the processing unit is used for acquiring command characters input by a user, sending the command characters to an operating system, receiving output characters fed back by the operating system and sending the output characters to the display unit;
and the display unit is used for displaying the output characters on an interface based on the swing component.
2. The swing-based interactable system command line tool in accordance with claim 1 wherein said processing element comprises:
the input processor is used for monitoring the command characters, processing the command characters and then sending the processed command characters to the operating system;
and the output processor is used for receiving the output characters fed back by the operating system, processing the output characters and then sending the processed output characters to the display unit.
3. The swing-based interactable system command line tool in accordance with claim 2 wherein said input processor is operative to:
judging the type of the command character;
when the command character is a text character, directly sending the command character to the operating system in a byte mode;
and when the command character is a control character, encoding the command character and sending the encoded command character to the operating system.
4. The swing-based interactable system command line tool in accordance with claim 3 wherein said output processor is operative to:
judging the type of the output character;
when the output character is a text character, directly sending the output character to the display unit in a byte mode;
and when the output character is a control character, decoding the output character and sending the decoded output character to the display unit.
5. The swing-based interactable system command line tool in accordance with claim 2 wherein said display unit is operative to:
and displaying the processed output character on an interface based on the swing component.
6. The swing-based interactable system command line tool in accordance with claim 5 wherein control characters of said command characters include at least one of the following characters: carriage return characters, tabulation characters, deletion characters, space characters, upper key characters, lower key characters, left key characters and right key characters.
7. The swing-based interactable system command line tool in accordance with claim 5 wherein said control characters of said output characters comprise a cursor.
8. The swing-based interactable system command line tool in accordance with claim 7 wherein said cursor states include a first state, a second state, and a third state;
the display unit is used for:
when the interface is selected, refreshing the interface to enable the cursor to be alternately presented between a first state and a second state;
when the interface is not selected, the cursor keeps a third state;
storing historical text characters;
and acquiring and displaying the historical text characters and the latest text characters with the corresponding number according to the size of the current interface.
9. The swing-based interactable system command line tool in accordance with claim 1 wherein said processing unit interacts with said operating system through a virtual terminal PTY.
10. Software characterized in that it integrates a swing-based interactable system command line tool according to any of claims 1-9.
CN202110577958.7A 2021-05-26 2021-05-26 Swing-based interactive system command line tool and software Pending CN113220288A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110577958.7A CN113220288A (en) 2021-05-26 2021-05-26 Swing-based interactive system command line tool and software

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110577958.7A CN113220288A (en) 2021-05-26 2021-05-26 Swing-based interactive system command line tool and software

Publications (1)

Publication Number Publication Date
CN113220288A true CN113220288A (en) 2021-08-06

Family

ID=77098613

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110577958.7A Pending CN113220288A (en) 2021-05-26 2021-05-26 Swing-based interactive system command line tool and software

Country Status (1)

Country Link
CN (1) CN113220288A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030210275A1 (en) * 2002-05-02 2003-11-13 Johann Draschwandtner Extensible command-line description mechanism for activating external tools
WO2004044785A1 (en) * 2002-11-12 2004-05-27 Thought, Inc. Dynamic transparent object querying generation and parsing
US20050021652A1 (en) * 2003-07-25 2005-01-27 Sun Microsystems, Inc. Synchronous collaborative shell integrated instant messaging
CN1740968A (en) * 2004-08-27 2006-03-01 华为技术有限公司 Tool command language integration development system
US20170270091A1 (en) * 2016-03-18 2017-09-21 Vmware, Inc. System and method for processing command line interface commands
US20200379736A1 (en) * 2019-05-29 2020-12-03 Red Hat, Inc. Services integration in an integrated development environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030210275A1 (en) * 2002-05-02 2003-11-13 Johann Draschwandtner Extensible command-line description mechanism for activating external tools
WO2004044785A1 (en) * 2002-11-12 2004-05-27 Thought, Inc. Dynamic transparent object querying generation and parsing
US20050021652A1 (en) * 2003-07-25 2005-01-27 Sun Microsystems, Inc. Synchronous collaborative shell integrated instant messaging
CN1740968A (en) * 2004-08-27 2006-03-01 华为技术有限公司 Tool command language integration development system
US20170270091A1 (en) * 2016-03-18 2017-09-21 Vmware, Inc. System and method for processing command line interface commands
US20200379736A1 (en) * 2019-05-29 2020-12-03 Red Hat, Inc. Services integration in an integrated development environment

Similar Documents

Publication Publication Date Title
CN1786952B (en) Integrated client help viewer for internet-based and local help content
CA1268556A (en) Multiple process, windowed display system
US20030189598A1 (en) System and method for displaying window contents
CN101566949A (en) Device and method for displaying control
CN100501617C (en) Programmable terminal system
CN111857453A (en) Function interface display method, computer equipment and storage medium
US5712994A (en) Method and system for apparent direct editing of transient graphic elements within a data processing system
US20130132891A1 (en) Apparatus and method of a mobile terminal using a dialog application having a notice function
JP2001060134A (en) Multiwindow control system
CN113220288A (en) Swing-based interactive system command line tool and software
JP2642040B2 (en) Method and system for apparently directly editing a fixed element displayed in a main window
US8788633B2 (en) Low bandwidth remote control of an electronic device
JP2000235447A (en) Display controller and storage medium
JPH02151924A (en) Multiwindow display system
JPH02158828A (en) Multiwindow link displaying method
JPH09258886A (en) Data input method
JPS6049429A (en) Graphic producer
CN111124336A (en) Distributed cloud splicing window pre-operation method and cloud splicing control platform
JP2700021B2 (en) Window display control device and method
JPH0525115B2 (en)
CN114546386A (en) Multi-control brushing method, device, equipment and storage medium
JP2513147B2 (en) Display controller
JP2504867B2 (en) Display method in text processing device
JPH11249783A (en) Information display device
JPH0934675A (en) Object operation system for three-dimensional virtual common space

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination