1. Field of the Invention
The present invention relates generally to interactive software engineering tools including editors for source code such as a programming or mark-up language, and more particularly to a language-based editing architecture with support for whitespace adjustment under user or program control.
2. Description of the Related Art
In an editor for computer programs, it may be desirable to adjust the horizontal length of displayed lines of source code. For example, a user may require, or simply prefer, a more spacious layout in order to read comfortably. Alternatively, a user may wish to see more information in a fixed amount of space. In some implementations, it may be desirable to adjust line length in conformance with a desired margin alignment (as in word processor paragraphs) or to optimize layout when long lines are wrapped (or folded) in some automatic way.
Whatever the motivation, it has generally been found that, to avoid degrading display legibility and distracting the user, adjustments to display length of lines are often best performed by adjusting the whitespace in the rendered text, rather than changing the rendering of the text elements themselves. For example, word processors commonly use whitespace adjustment in the presentation of fully justified text.
In contrast with the information manipulated and rendered by text-oriented editors such as a word processor, computer programs tend to exhibit a structural content that advanced software engineering tools may consider in their functionality or behavior. For example, computer program editors often attempt to highlight certain constructs such as keywords, conditions, grouping constructs (such as parenthesis or braces), etc. Other examples of language-oriented behavior include “prettyprinting.” Over the years, several approaches have been employed to provide language-oriented features in software engineering tools. Some tools, such as the GNU Emacs editor familiar to many programmers, take a text-oriented approach based on regular expression matching to provide language-specialized services. Others, particularly in research systems, have employed structure-based approaches. See e.g., Tim Teitelbaum and Thomas Reps, The Cornell Program Synthesizer: A Syntax-Directed Programming Environment, Communications of the ACM, 24, 9, pp. 563–573 (1981). Most practical systems attempt to combine aspects of the two approaches.
Indeed, applicant's U.S. Pat. No. 5,748,975, entitled “SYSTEM AND METHOD FOR TEXTUAL EDITING OF STRUCTURALLY-REPRESENTED COMPUTER PROGRAMS WITH ON-THE-FLY TYPOGRAPHICAL DISPLAY,” discloses an especially user-friendly editor for structurally represented computer programs. That editor combined aspects of text and structure editors by transforming the event stream typed by a user into a token stream, where tokens of the token stream constituted elements of the program being entered. Each token was classified by the editor as corresponding to a group of extended lexemes defined by the language in which the program under edit was written. The editor prettyprinted a program as the user typed, using information in the token stream, and further allowed the user to edit the program from the prettyprinted display as though the program were internally represented as text.
Applicant's U.S. Pat. No. 5,752,058, entitled “SYSTEM AND METHOD FOR INTER-TOKEN WHITESPACE REPRESENTATION AND TEXTUAL EDITING BEHAVIOR IN A PROGRAM EDITOR,” improves upon the aforementioned techniques for displaying code. Based on information in the token stream, the disclosed editor prettyprinted the program as the user types. In some realizations disclosed, the prettyprinting step involved typesetting each of the tokens in a visually distinct manner and displaying a selected amount of visual whitespace between the tokens based on the lexical types of the tokens.
However notwithstanding the advantages provided by an editor according to either or both of the '975 and '058 patents, a user staring at a display while entering and editing text can still become visually fatigued. Thus, while conventional prettyprinting can make entering and editing computer program code somewhat less fatiguing, there is still a need for techniques to further enhance or vary a language-based display.
Accordingly, it has been discovered that an editor or software engineering tool may be configured to render whitespace between adjacent tokens, wherein the amount of whitespace between any two adjacent tokens is determined according to language-specific style rules and scaled in accordance with display considerations. In some realizations, the operative scaling is selected or defined by a user according to the user's visual preferences. In some realizations, the operative scaling relates to requirements or constraints of an automated layout mechanism. For example, a particular scaling may be calculated to adjust line length in conformance with a desired margin alignment or to optimize layout when long lines are automatically wrapped (or folded) in some automatic way.
In one embodiment in accordance with the present invention, a software engineering tool recognizes language tokens and computes for display whitespace amounts between adjacent instances thereof according to language-specific style rules. The software engineering tool further provides, for at least a grouping of those language tokens displayed, dynamic adjustment of the computed whitespace amounts in accordance with an operative scaling factor therefor.
In another embodiment in accordance with the present invention, a method of presenting textual content that includes a sequence of tokens recognizable in accordance with a predefined language model includes calculating whitespace amounts for visual presentation between adjacent pairs of recognized tokens, wherein the calculated whitespace amount for visual presentation between a first pair of the tokens differs from that between a second pair of the tokens, each in accordance with language-specific style rules; and for at least a subset of the token sequence, applying an operative scaling factor in the calculating of respective ones of the whitespace amounts.
In another embodiment in accordance with the present invention, a process for visual whitespace representation and cursor behavior in a software engineering tool configured to represent a computer program as a sequence of tokens includes displaying each line of the computer program as it is entered by a user, wherein a displayed line includes a portion of the sequence of tokens and visual whitespace separating adjacent ones thereof, and wherein width of a particular instance of visual whitespace is based on (i) lexical type of at least one respective token adjacent thereto and (ii) an operative scaling factor, such that, for a given view, the width of each instance of visual whitespace is language sensitive and modulated in accordance with the operative scaling factor. The method further includes displaying a cursor in the displayed line of the computer program, the cursor having a cursor position corresponding to an insertion point in the sequence.
In still another embodiment in accordance with the present invention, a computer program product including instructions encoded at least one computer readable medium and executable on a processor. The computer program product includes first and second functional sequences. The first functional sequence of the instructions directs the processor to calculate a sizing for a particular instance of whitespace to be displayed adjacent to a particular display element corresponding to a language token recognized in a sequence thereof, the calculated sizing being at least a function of the recognized language token. The second functional sequence of the instructions directs the processor to calculate an adjustment to the sizing, the adjustment being in accordance with an operative scaling factor.
In still yet another embodiment in accordance with the present invention, an apparatus includes storage for a computer readable encoding of information represented as a sequence of tokens, means for preparing a visual representation of the token sequence as display elements separated by whitespace, wherein sizing of a particular instance of the whitespace is in accordance with (i) the tokens adjacent thereto and (ii) an operative scaling factor, and means for adjusting the operative scaling factor.
The present invention may be better understood, and its numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings.
The use of the same reference symbols in different drawings indicates similar or identical items.
Exploitations of the techniques of the present invention are many. In particular, a wide variety of software engineering tools that employ aspects of the present invention to facilitate language-sensitive whitespace adjustment are envisioned. One exemplary software engineering tool with language-oriented behavior is a source code editor that provides advanced program typography based on lexical context. Such a source code editor provides a useful descriptive context in which to present various aspects of the present invention. Nonetheless, the invention is not limited thereto. Indeed, applications to editors, analyzers, builders, compilers, debuggers and other such software engineering tools are envisioned. In this regard, some exploitations of the present invention may provide language-oriented behaviors within suites of tools or within tools that provide functions in addition to manipulation of program code.
In addition, while traditional procedural or object-oriented programming languages provide a useful descriptive context, exploitations of the present invention are not limited thereto. Indeed, other software engineering tool environments such as those adapted for editing, analysis, manipulation, transformation, compilation, debugging or other operations on functionally descriptive information or code, such as other forms of source code, machine code, bytecode sequences, scripts, macro language directives or information encoded using markup languages such as HTML or XML, may also employ structures, methods and techniques in accordance with the present invention. Furthermore, the structures, methods and techniques of the present invention may be exploited in the manipulation or editing of non-functional, descriptive information, such as software documentation or even prose, as long as rendered whitespace is a function of lexical context and an operative scaling. Based on the description herein, persons of ordinary skill in the art will appreciate applications to a wide variety of tools and language contexts.
Accordingly, in view of the above and without limitation, an exemplary exploitation of the present invention is now described.
Exemplary Editor Implementation
In general, techniques of the present invention may be implemented using any of a variety of editor implementations. Nonetheless, for purposes of illustration, description of an exemplary set of editor implementations in U.S. Pat. No. 5,752,058, entitled “SYSTEM AND METHOD FOR INTER-TOKEN WHITESPACE REPRESENTATION AND TEXTUAL EDITING BEHAVIOR IN A PROGRAM EDITOR” is incorporated herein by reference. Based on the description herein, including the above-incorporated description, persons of ordinary skill in the art will appreciate a variety of editor implementations that may benefit from features and techniques of the present invention.
In the illustrated editor implementation, a user edits the program by interacting, through input device 112, with the displayed version 118 of the program being edited. In implementations where input device 112 includes a keyboard, these interactions may include keystrokes directing the editor to update insertion point 157 (e.g., in response to use of cursor control keys), insert a space at a current insertion point (e.g., in response to spacebar use), delete the editable element to the left or right of the cursor, insert a character at the cursor (upon typing), or break the current line (e.g., in response to use of the enter key). If the input device 112 also includes a mouse, interactions may also include various types of mouse clicks, selections and/or menu operations. The input device relays interactions, or input events, to the keystroke executive 130 as an event stream 113. In general, during operation of the editor implementation, the state of program representation 156 includes accumulated contributions of keystroke executive 130 and any program code loaded from file or other storage (not shown).
Tokenizer 132 is of any suitable design that, based on lexical rules 168a, identifies tokens in program representation 156. Because changes to the state of program representation 156 are responsive to event stream 113, typical implementations place tokenizer or lexical analysis functions under control of keystroke executive 130. Nonetheless, in other software engineering tool implementations, particularly those that emphasize display, rather than editing of program code, lexical analysis may be more closely linked with other functionality. In some variations, language specific tokenizers (not specifically shown) may be provided to handle embedded lexical contexts such as for comments, strings, scripts etc. In such cases, token stream 158 includes tokens recognized in accordance with the various operative lexical contexts. In some variations, certain content such as comments may be separately processed (e.g., by comment processor 136) and represented as part of program representation 156 as annotations (see annotation list 160) or other ancillary data. In some realizations, structural (e.g., syntactic) analysis 150 may be performed and program representation 156 may include a syntax tree 162 or other similar component of the tokenized program representation.
Whatever the tokenized representation of program code, typographic display processor 170 provides a corresponding language-sensitive rendition using display 118. Above-incorporated U.S. Pat. No. 5,752,058 describes in detail one suitable implementation of typographic display processor 170 functionality in which lexical information (and in some cases syntactic information) is used to determine the display attributes of textual content. In particular,
For purposes of some embodiments of the present invention in which variable amount of whitespace between adjacent tokens is determined according to language-specific style rules and scaled in accordance with display considerations (whether user-oriented display considerations, layout-oriented display considerations or otherwise), any of a variety of mechanisms for token recognition, assignment of typographic attributes or selection of a base whitespace amount are suitable. The implementation described above is but one such implementation. Preferably, whitespace between tokens is not explicitly represented in token stream 158, but rather, is implicitly coded by language-specific display rules, for example using a table that maps adjacent token pairings (or token type pairings) to a whitespace amount. Nonetheless, based on the description herein, persons of ordinary skill in the art will recognize implementations in which whitespace, though dependent on recognized language content and scaled or modulated based on display considerations, is encoded explicitly in a token stream or other program representation. Recognizing the diversity of available design alternatives, the description that follows focuses on functional flows, rather than particular representation formats.
Language-Sensitive Whitespace Adjustment
Some embodiments in accordance with the present invention extend the above-described display capabilities by permitting dynamic adjustments to be made to a horizontal whitespace computation. In general, the adjustments may be made either automatically or under user control. Adjustments may apply to all lines in a particular view (multiple views are typically permitted) or to particular lines within a particular view.
Recognizing the range of suitable variations, the illustrative configuration of
By providing adjustment 205, the language sensitive whitespace that is otherwise determined (e.g., in accordance with whitespace rules 204B) is scaled or modulated in accordance with the desired adjustment. Accordingly, the rendered width of whitespace 211, 212 and 213 is actually dependent both on the particular language features of the rendered textual content and the adjustment. Typical sources of adjustment include the user himself/herself and automatic layout mechanisms of rendering engine 203.
While any of a variety of adjustment mechanisms may be employed,
In a simple realization, the user is offered a control mechanism associated with each view that permits adjustment to the language-sensitive horizontal spacing. A number of choices may be offered, ranging from very small spacing (language tokens packed very densely) to very large spacing (language tokens widely separated). In some presentations, a clearly identified default setting may be provided. Typically, the default setting is the preferred spacing for the particular set of style rules being used.
A more complex realization applies an adjustment separately to each line in a view. As before, the adjustment may be placed under control of the user. However, such line-by-line adjustment is more likely placed under control of the automatic layout mechanism, for example, to adjust the length of particular lines for a reason such as optimizing layout when long lines are being automatically broken or folded. Note that aspects of both user and automatic adjustment realizations may coexist. For example, a user may select a preferred horizontal density of tokens, but the result may subsequently be modulated on particular lines by another layout mechanism.
Although suitable selections of whitespace amounts and modulations may trace to any of a variety sources including ad hoc selections of whitespace and empirically determined scalings, one presently preferred source of human factors oriented data for horizontal whitespace follows guidelines for visual styles described in Ronald M. Baecker and Aaron Marcus, Human Factors and Typography for More Readable Programs, ACM Press, 1990, pp. 334. Embodiments in accordance with the present invention may employ any of a number of sources of whitespace data or computations with further adjustment (e.g., dynamically, each time a line is displayed) by an additional scaling factor that may be changed by a user or under automatic control.
In some realizations, the selected factor scales whitespace linearly. Linear scaling coefficients are typically determined empirically, based on the visual effect of each. In some realizations, the scaling factor may be non-linear, taking into account the non-linearity of human visual perception. Likewise, the set of scaling factors presented to the user could be computed automatically. In yet another realization, the choice of scaling factors may be presented to the user as a linear scale, rather than discrete choices, for example using conventional “slider” controls for a graphical toolkit. Based on the description herein, persons of ordinary skill in the art will appreciate any of a variety of user interface designs.
While the invention has been described with reference to various embodiments, it will be understood that these embodiments are illustrative and that the scope of the invention is not limited to them. Many variations, modifications, additions, and improvements are possible. In particular, a wide variety of lexical contexts may be supported. For example, while a lexical context typical of program code has been illustrated, other lexical contexts such as those appropriate to markup languages, comments, even multimedia content may be supported. Similarly, although much of the description has focused on functionality of an editor, the techniques described herein may apply equally to other interactive or even batch oriented tools. While lexical analysis of textual content has been presumed in many illustrations, persons of ordinary skill in the art will recognize that the techniques described herein also apply to structure-oriented editors and to implementations that provide syntactic, as well as lexical, analysis of content.
More generally, plural instances may be provided for components described herein as a single instance. Boundaries between various components, operations and data stores are somewhat arbitrary, and particular operations are illustrated in the context of specific illustrative configurations. Other allocations of functionality are envisioned. Structures and functionality presented as discrete in the exemplary configurations may be implemented as a combined structure or component. These and other variations, modifications, additions, and improvements may fall within the scope of the invention as defined in the claims that follow.
| Number | Name | Date | Kind |
|---|---|---|---|
| 4809170 | Leblang et al. | Feb 1989 | A |
| 4931928 | Greenfeld | Jun 1990 | A |
| 4989145 | Kyushima | Jan 1991 | A |
| 5006992 | Skeirik | Apr 1991 | A |
| 5070478 | Abbott | Dec 1991 | A |
| 5079700 | Kozoll et al. | Jan 1992 | A |
| 5140521 | Kozol et al. | Aug 1992 | A |
| 5239298 | Wei | Aug 1993 | A |
| 5263174 | Layman | Nov 1993 | A |
| 5287501 | Lomet | Feb 1994 | A |
| 5293629 | Conley et al. | Mar 1994 | A |
| 5311422 | Loftin et al. | May 1994 | A |
| 5313387 | McKeeman et al. | May 1994 | A |
| 5377318 | Wolber | Dec 1994 | A |
| 5430836 | Wolf et al. | Jul 1995 | A |
| 5481711 | Sotani | Jan 1996 | A |
| 5481712 | Silver et al. | Jan 1996 | A |
| 5485618 | Smith | Jan 1996 | A |
| 5493678 | Arcuri et al. | Feb 1996 | A |
| 5502805 | Anderson et al. | Mar 1996 | A |
| 5513305 | Maghbouleh | Apr 1996 | A |
| 5537630 | Berry et al. | Jul 1996 | A |
| 5557730 | Frid-Nielsen | Sep 1996 | A |
| 5577241 | Spencer | Nov 1996 | A |
| 5579469 | Pike | Nov 1996 | A |
| 5583762 | Shafer | Dec 1996 | A |
| 5604853 | Nagashima | Feb 1997 | A |
| 5627958 | Potts et al. | May 1997 | A |
| 5628016 | Kukol | May 1997 | A |
| 5644737 | Tuniman et al. | Jul 1997 | A |
| 5649192 | Stucky | Jul 1997 | A |
| 5649222 | Mogilevsky | Jul 1997 | A |
| 5671403 | Shekita et al. | Sep 1997 | A |
| 5673390 | Mueller | Sep 1997 | A |
| 5680619 | Gudmundson et al. | Oct 1997 | A |
| 5680630 | Saint-Laurent | Oct 1997 | A |
| 5694559 | Hobson et al. | Dec 1997 | A |
| 5724593 | Hargrave, III et al. | Mar 1998 | A |
| 5734749 | Yamada et al. | Mar 1998 | A |
| 5737608 | Van De Vanter | Apr 1998 | A |
| 5740444 | Frid-Nielsen | Apr 1998 | A |
| 5748975 | Van De Vanter | May 1998 | A |
| 5752058 | Van De Vanter | May 1998 | A |
| 5754737 | Gipson | May 1998 | A |
| 5781720 | Parker et al. | Jul 1998 | A |
| 5790778 | Bush et al. | Aug 1998 | A |
| 5798757 | Smith | Aug 1998 | A |
| 5802262 | Van De Vanter | Sep 1998 | A |
| 5805889 | Van De Vanter | Sep 1998 | A |
| 5813019 | Van De Vanter | Sep 1998 | A |
| 5825355 | Palmer et al. | Oct 1998 | A |
| 5844554 | Geller et al. | Dec 1998 | A |
| 5845120 | Reddy et al. | Dec 1998 | A |
| 5845300 | Comer et al. | Dec 1998 | A |
| 5850561 | Church et al. | Dec 1998 | A |
| 5857212 | Van De Vanter | Jan 1999 | A |
| 5859638 | Coleman et al. | Jan 1999 | A |
| 5870608 | Gregory | Feb 1999 | A |
| 5872974 | Mezick | Feb 1999 | A |
| 5877758 | Seybold | Mar 1999 | A |
| 5890103 | Carus | Mar 1999 | A |
| 5905892 | Nielsen et al. | May 1999 | A |
| 5911059 | Profit, Jr. | Jun 1999 | A |
| 5911075 | Glaser et al. | Jun 1999 | A |
| 5924089 | Mocek et al. | Jul 1999 | A |
| 5959629 | Masui | Sep 1999 | A |
| 5990906 | Hudson et al. | Nov 1999 | A |
| 6012075 | Fein et al. | Jan 2000 | A |
| 6016467 | Newsted et al. | Jan 2000 | A |
| 6018524 | Turner et al. | Jan 2000 | A |
| 6023715 | Burkes et al. | Feb 2000 | A |
| 6026233 | Shulman et al. | Feb 2000 | A |
| 6053951 | McDonald et al. | Apr 2000 | A |
| 6061513 | Scandura | May 2000 | A |
| 6071317 | Nagel | Jun 2000 | A |
| 6115544 | Mueller | Sep 2000 | A |
| 6119120 | Miller | Sep 2000 | A |
| 6154847 | Schofield et al. | Nov 2000 | A |
| 6163879 | Mackey | Dec 2000 | A |
| 6185591 | Baker et al. | Feb 2001 | B1 |
| 6205579 | Southgate | Mar 2001 | B1 |
| 6226785 | Peterson et al. | May 2001 | B1 |
| 6247020 | Minard | Jun 2001 | B1 |
| 6266665 | Vaidyanathan et al. | Jul 2001 | B1 |
| 6275976 | Scandura | Aug 2001 | B1 |
| 6282551 | Anderson et al. | Aug 2001 | B1 |
| 6286138 | Purcell | Sep 2001 | B1 |
| 6470306 | Pringle et al. | Oct 2002 | B1 |
| 6470349 | Heninger et al. | Oct 2002 | B1 |
| 6601026 | Appelt et al. | Jul 2003 | B1 |
| 6658624 | Savitzky et al. | Dec 2003 | B1 |
| 6760695 | Kuno et al. | Jul 2004 | B1 |
| Number | Date | Country | |
|---|---|---|---|
| 20030066058 A1 | Apr 2003 | US |