CN111126011A - Method and device for processing right alignment of text, storage medium and processor - Google Patents

Method and device for processing right alignment of text, storage medium and processor Download PDF

Info

Publication number
CN111126011A
CN111126011A CN201911360788.6A CN201911360788A CN111126011A CN 111126011 A CN111126011 A CN 111126011A CN 201911360788 A CN201911360788 A CN 201911360788A CN 111126011 A CN111126011 A CN 111126011A
Authority
CN
China
Prior art keywords
character string
text
original
target
strings
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
CN201911360788.6A
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.)
Beijing Zhongxiaoyun Iot Institute Co ltd
Original Assignee
Beijing Zhongxiaoyun Iot Institute 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 Beijing Zhongxiaoyun Iot Institute Co ltd filed Critical Beijing Zhongxiaoyun Iot Institute Co ltd
Priority to CN201911360788.6A priority Critical patent/CN111126011A/en
Publication of CN111126011A publication Critical patent/CN111126011A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a processing method and device for right alignment of texts, a storage medium and a processor. Wherein, the method comprises the following steps: acquiring a plurality of original texts from a plurality of text function controls, wherein each text function control is used for inputting and displaying each original text; acquiring an original character string corresponding to each original text to obtain a plurality of original character strings; acquiring a plurality of target character strings corresponding to a plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one by one, and the left side of at least one first character string in the plurality of target character strings comprises at least one space so that the display width of each target character string is the same; in each text functionality control, the corresponding target text is displayed in right-justified manner based on the display width of each corresponding target character string. The method solves the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated.

Description

Method and device for processing right alignment of text, storage medium and processor
Technical Field
The present invention relates to the field of text processing, and in particular, to a method and an apparatus for right-justified processing of a text, a storage medium, and a processor.
Background
Currently, when implementing a right justified display of text, it is common to right justifie each line of text in one text functionality control. For the right alignment display of the texts in the text function controls, the user usually fills in the texts in all the text function controls, the text width needs to be calculated manually and repeatedly, and the right alignment display of the texts is set according to the manually calculated text width. The method is complicated in operation, and when the width of the text is changed, the right alignment display of the text in the text function controls cannot be changed in time, so that the technical problem of low efficiency of the right alignment display of the text exists.
Aiming at the technical problem that the efficiency of right alignment display of the text is low due to the fact that the width of the text needs to be calculated manually and repeatedly and the right alignment of the text is achieved manually, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for processing right alignment of a text, a storage medium and a processor, which are used for at least solving the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated.
According to an aspect of an embodiment of the present invention, a method for processing right alignment of a text is provided. The method can comprise the following steps: acquiring a plurality of original texts from a plurality of text function controls, wherein each text function control is used for inputting and displaying each original text; acquiring an original character string corresponding to each original text to obtain a plurality of original character strings; acquiring a plurality of target character strings corresponding to a plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one by one, and the left side of at least one first character string in the plurality of target character strings comprises at least one space so that the display width of each target character string is the same; in each text functionality control, the corresponding target text is displayed in right-justified manner based on the display width of each corresponding target character string.
Optionally, before obtaining a plurality of target character strings corresponding to a plurality of original character strings, the method further includes: acquiring a second character string with the longest display width from the plurality of original character strings; adding continuous at least one space to the left side of each third character string based on the display width of the second character string to adjust the display width of each third character string, wherein each third character string is a character string except the second character string in the plurality of original character strings, and the adjusted display width of each third character string is the same as the display width of the second character string; and determining each adjusted third character string as a target character string corresponding to each third character string, wherein the target character string corresponding to the second character string is still the second character string.
Optionally, adding a continuous at least one space to the left of each third string based on the display width of the second string comprises: acquiring a width difference between the display width of the second character string and the display width of each third character string; adding a continuous at least one space to the left of each third string based on the width difference.
Optionally, adding a consecutive at least one space to the left of each third string based on the width difference comprises: determining a target number of consecutive at least one space based on the width difference; a target number of spaces are added to the left side of each third string.
Optionally, adding a target number of spaces to the left of each third string comprises: an adding step of adding a space to the left side of each third character string; and a first judgment step of judging whether the number of the added spaces on the left side of each third character string reaches the target number, if not, returning to the adding step, and if so, ending the step.
Optionally, adding a continuous at least one space to the left of each third string based on the display width of the second string comprises: an adding step of adding a space to the left side of each third character string; and a second judging step of judging whether the display width of the third character string with the added space reaches the display width of the second character string, if not, returning to the adding step, and if so, ending the step.
Optionally, the method further comprises: taking each third character string as a target key; taking the target character string corresponding to each third character string as a target value; storing the target key and the target value through a key-value pair; acquiring a plurality of target character strings corresponding to a plurality of original character strings includes: a plurality of target character strings corresponding to the plurality of original character strings are acquired based on the key-value pairs.
Optionally, each original text is a prompt text for prompting a text to be input, and the text to be input corresponding to each prompt text is displayed in left alignment.
According to another aspect of the embodiment of the invention, a device for processing right alignment of texts is also provided. The apparatus may include: the device comprises a first acquisition unit, a second acquisition unit and a display unit, wherein the first acquisition unit is used for acquiring a plurality of original texts from a plurality of text function controls, and each text function control is used for inputting and displaying each original text; the second acquisition unit is used for acquiring the original character string corresponding to each original text to obtain a plurality of original character strings; a third acquiring unit configured to acquire a plurality of target character strings corresponding to a plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one to one, and a left side of at least one first character string in the plurality of target character strings includes at least one space so that display widths of the target character strings are the same; and the display unit is used for displaying the corresponding target text in a right alignment mode on the basis of the display width of each corresponding target character string in each text function control.
According to another aspect of the embodiments of the present invention, there is also provided a storage medium. The storage medium comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the processing method for right alignment of the text of the embodiment of the invention.
According to another aspect of the embodiments of the present invention, there is also provided a processor. The processor is used for running a program, wherein the program executes the processing method for right alignment of the text in the embodiment of the invention when running.
In the embodiment of the invention, a plurality of original texts are obtained from a plurality of text function controls, wherein each text function control is used for inputting and displaying each original text; acquiring an original character string corresponding to each original text to obtain a plurality of original character strings; acquiring a plurality of target character strings corresponding to a plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one by one, and the left side of at least one first character string in the plurality of target character strings comprises at least one space so that the display width of each target character string is the same; in each text functionality control, the corresponding target text is displayed in right-justified manner based on the display width of each corresponding target character string. That is to say, the invention determines the original character string corresponding to each original text in each text function control, then obtains the target character string according to the corresponding relationship between the original character string and the target character string, the target character string corresponding to each original character string can achieve the purpose that the display width of each target character string is the same by adding a space to the left side of the original character string, and further displays the corresponding target text in right alignment based on the display width of each corresponding target character string, thereby achieving the purpose of simplifying the right alignment display of the texts in a plurality of text function controls, and achieving the purpose of performing batch right alignment display of the texts in a plurality of text function controls, even when the display width of the text with the longest display width is changed, the display widths of other texts can automatically change along with the display width in time, therefore, the technical effect of improving the efficiency of right alignment display of the text is achieved, and the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart of a method of processing right alignment of text in accordance with an embodiment of the present invention;
FIG. 2 is a schematic illustration of a text display according to the related art;
FIG. 3 is a schematic diagram of a right justified display of text in accordance with an embodiment of the present invention; and
fig. 4 is a schematic diagram of a device for right-justified processing of text, according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with an embodiment of the present invention, there is provided an embodiment of a method of right-justified processing of text, it is noted that the steps illustrated in the flowchart of the drawing may be performed in a computer system such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 1 is a flowchart of a processing method for right alignment of text according to an embodiment of the present invention. As shown in fig. 1, the method may include the steps of:
step S102, a plurality of original texts are obtained from a plurality of text function controls.
In the technical solution provided in step S102, each text function control is used to input and display each original text.
In this embodiment, in an Android (Android) user interaction process design, a plurality of original texts may be acquired from a plurality of text function controls, and the plurality of text function controls may be list controls for performing text display, may be a custom text display control TextView, and may also be input boxes in other forms, which is not limited herein. Each text function control is used for inputting corresponding display original texts and simultaneously can be used for displaying the original texts, namely, a plurality of text function controls correspond to a plurality of original texts one by one, and the plurality of original texts are original texts to be displayed in a batch right alignment mode.
Optionally, each original text of the embodiment is a prompt text for prompting a text to be input. The original text includes, but is not limited to, a prompt text for prompting the user to input a text to be filled in the text function control, for example, the prompt text may be "consignee", for prompting the user to input a name of a specific consignee in the text function control, the name of the consignee is the text to be input, and for example, the original text may be "mobile phone number", for prompting the user to input contents of the specific mobile phone number in the text function control, the contents of the mobile phone number are the text to be input, and no limitation is made herein.
The display widths of the plurality of original texts of this embodiment may be different, for example, the display widths of the above-mentioned "consignee" and "mobile phone number" are different, wherein the display width of the "mobile phone number" is larger than the display width of the "consignee".
Step S104, obtaining the original character string corresponding to each original text to obtain a plurality of original character strings.
In the technical solution provided in step S104, after a plurality of original texts are acquired from a plurality of text function controls, an original character string corresponding to each original text is acquired, so as to obtain a plurality of original character strings. The plurality of original character strings of the embodiment may be in one character string set, and each original character string may be used to represent text information of an original text that needs to be displayed in right alignment, that is, text information of all original texts that need to be displayed in right alignment is collected through one character string set.
Step S106, a plurality of target character strings corresponding to the plurality of original character strings are obtained.
In the technical solution provided in step S106, after obtaining an original character string corresponding to each original text and obtaining a plurality of original character strings, obtaining a plurality of target character strings corresponding to the plurality of original character strings, where the plurality of original character strings correspond to the plurality of target character strings one to one, and a left side of at least one first character string in the plurality of target character strings includes at least one space, so that display widths of the target character strings are the same, and the display width of each target character string is a width of a target text corresponding to each target character string.
In this embodiment, each original character string has a corresponding target character string, each target character string is obtained by traversing each original character string by adding at least one space "\ u00A 0" to the left side of each original character string, and the display width of each target character string is the same.
And S108, in each text function control, displaying the corresponding target text in a right alignment mode based on the display width of each corresponding target character string.
In the technical scheme provided in step S108, after a plurality of target character strings corresponding to a plurality of original character strings are acquired, in each text function control, a target text corresponding to each target character string is displayed in a right-aligned manner based on the display width of each corresponding target character string, so as to achieve an effect that each target text is displayed in a right-aligned manner in the corresponding text function control, and further achieve a purpose of performing batch right-aligned display on the plurality of original texts, where the target text is the same as the original text in content.
Optionally, when each original text is a prompt text and is used for prompting a text to be input, in each text function control, when the corresponding target text is displayed in a right-aligned manner based on the display width of each corresponding target character string, the text to be input corresponding to each prompt text may be displayed in a left-aligned manner, so that the prompt text is aligned with the central axis of the corresponding text to be input and extends to both sides, thereby improving user experience and avoiding uneven display of the text to be input corresponding to the prompt text on the right side due to different display widths (consignee/mobile phone numbers) of the prompt text.
Through the steps S102 to S108, the original character string corresponding to each original text in each text function control is determined, then the target character string is obtained according to the corresponding relation between the original character string and the target character string, the target character string corresponding to each original character string can achieve the purpose that the display width of each target character string is the same by adding a space to the left side of the original character string, and further the corresponding target text is displayed in a right alignment mode based on the display width of each corresponding target character string, so that the purpose of simplifying the right alignment display of the texts in a plurality of text function controls is achieved, the purpose of performing batch right alignment display on the texts in the plurality of text function controls is achieved, and the problem that the display width of other texts cannot be changed in time when the display width of the text with the longest display width is changed is avoided, therefore, the technical effect of improving the efficiency of right alignment display of the text is achieved, and the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated is solved.
The above method of this embodiment is further described below.
As an optional implementation manner, before acquiring a plurality of target character strings corresponding to a plurality of original character strings in step S106, the method further includes: acquiring a second character string with the longest display width from the plurality of original character strings; adding continuous at least one space to the left side of each third character string based on the display width of the second character string to adjust the display width of each third character string, wherein each third character string is a character string except the second character string in the plurality of original character strings, and the adjusted display width of each third character string is the same as the display width of the second character string; and determining each adjusted third character string as a target character string corresponding to each third character string, wherein the target character string corresponding to the second character string is still the second character string.
In this embodiment, before obtaining a plurality of target character strings corresponding to a plurality of original character strings, a correspondence relationship between the original character strings and the target character strings may be determined, the plurality of original character strings may be traversed, a display width of each original character string, that is, a width of an original text corresponding to each original character string may be calculated, a second character string having a longest display width may be obtained from the plurality of original character strings, a character string other than the second character string in the plurality of original character strings is a third character string, the plurality of target character strings include the second character string and a third character string, a display width of the third character string is smaller than a display width of the second character string, the number may be plural, and at least one continuous space may be added to a left side of each third character string based on the display width of the second character string, so that the display widths of the plurality of third character strings may be adjusted, and enabling the display widths of the plurality of third character strings to be the same, wherein each adjusted third character string is the character string spliced by each corresponding second character string and at least one space, and further determining each adjusted third character string as a target character string corresponding to each third character string. Since the second character string has the longest display width, the target character string corresponding to the second character string is still itself without adding at least one space to the left side, that is, the left side of the target character string includes 0 spaces. The method does not need human participation, avoids the defect that the display widths of other texts cannot be changed in time when the display width of the text with the longest display width is changed, can dynamically acquire the longest display width, measures the display widths of other texts in real time, automatically adjusts the display widths of other displayed texts along with the longest display width, reduces development time cost caused by adjustment of the display widths, and improves the efficiency of right-aligned display of the texts.
A method of adding at least one continuous space to the left side of each third character string based on the display width of the second character string of this embodiment will be described below.
As an alternative embodiment, adding a continuous at least one space to the left of each third character string based on the display width of the second character string includes: acquiring a width difference between the display width of the second character string and the display width of each third character string; adding a continuous at least one space to the left of each third string based on the width difference.
In this embodiment, each third character string may be traversed, the display width of each third character string may be calculated, a width difference between the display width of the second character string and the display width of each third character string may be obtained, and then at least one continuous blank space may be added to the left side of each third character string based on the width difference, so that the display width of each adjusted third character string may reach the display width of the second character string.
As an alternative embodiment, adding a continuous at least one space to the left side of each third string based on the width difference comprises: determining a target number of consecutive at least one space based on the width difference; a target number of spaces are added to the left side of each third string.
In this embodiment, in implementing the adding of the consecutive at least one space to the left side of each third string based on the width difference, the target number of consecutive at least one space may be determined first based on the width difference. When the number of the spaces added to the left side of each third character string reaches the target number, the adjusted display width of each third character string may reach the display width of the second character string.
As an alternative embodiment, adding a target number of spaces to the left of each third string comprises: an adding step of adding a space to the left side of each third character string; and a first judgment step of judging whether the number of the added spaces on the left side of each third character string reaches the target number, if not, returning to the adding step, and if so, ending the step.
In this embodiment, when the target number of spaces is added to the left side of each third character string, the adding step and the first judging step may be performed in a loop. Alternatively, when the adding step is performed, a space may be added to the left side of each third character string, and then the first judging step is performed to judge whether the number of spaces added to the left side of each third character string so far reaches the target number, and if it is judged that the number of spaces added to the left side of each third character string has reached the target number, it indicates that the display width of each third character string after the target number of spaces is added has reached the display width of the second character string; and if the number of the added spaces to the left side of each third character string is judged not to reach the target number, returning to the adding step, and adding a space to the left side of each third character string continuously, wherein a space is added immediately after the added space to the left side of each third character string last time, and circulating until the number of the added spaces to the left side of each third character string reaches the target number.
As an alternative embodiment, adding a continuous at least one space to the left of each third character string based on the display width of the second character string includes: an adding step of adding a space to the left side of each third character string; and a second judging step of judging whether the display width of the third character string with the added space reaches the display width of the second character string, if not, returning to the adding step, and if so, ending the step.
In this embodiment, when adding at least one continuous space to the left side of each third character string based on the display width of the second character string is implemented, the implementation can be further performed by: executing an adding step, namely adding a space to the left side of each third character string, then executing a second judging step, judging whether the display width of the third character string with the space added at present reaches the display width of the second character string, and finishing adding a space to the left side of each third character string if the display width of the third character string with the space added at present is judged to reach the display width of the second character string; and if the display width of the third character string after the blank is added is judged not to reach the display width of the second character string, continuously returning to the adding step, and continuously adding a blank to the left side of each third character string, wherein a blank is added immediately after the left added blank of each third character string last time, and circulating until the number of the blanks added to the left side of each third character string reaches the target number.
As an optional implementation, the method further comprises: taking each third character string as a target key; taking the target character string corresponding to each third character string as a target value; storing the target key and the target value through a key-value pair; acquiring a plurality of target character strings corresponding to a plurality of original character strings includes: a plurality of target character strings corresponding to the plurality of original character strings are acquired based on the key-value pairs.
In this embodiment, each adjusted third character string is determined as a target character string corresponding to each third character string, the result may be returned in the form of Map, with each third string as a destination Key (Key), with the destination string corresponding to each third string as a destination Value (Value), with the destination Key and destination Value being stored by a Key-Value pair, and when a plurality of destination strings corresponding to a plurality of original strings are acquired, can be directly called through the corresponding relation of key-value, a plurality of target character strings corresponding to a plurality of original character strings are obtained based on the key-value, and then, in each text function control, based on the display width of each corresponding target character string, displaying the corresponding target text in a right alignment manner, so that the effect of performing right alignment display on the target text in each text function control is realized.
In the embodiment, by the method, the original character string corresponding to each original text in each text function control is determined, then the target character string is obtained according to the corresponding relationship between the original character string and the target character string, the target character string corresponding to each original character string can achieve the purpose that the display widths of the target character strings are the same by adding a space to the left side of the original character string, and further, the corresponding target text is displayed in a right alignment mode based on the display width of each corresponding target character string, so that the purpose of simplifying the right alignment display of the texts in a plurality of text function controls is achieved, the purpose of performing batch right alignment display of the texts in the plurality of text function controls is achieved, and the problem that the display widths of other texts cannot change in time when the display width of the text with the longest display width changes is avoided, therefore, the longest display width can be dynamically obtained, the display widths of other texts are measured in real time, the display widths of the other displayed texts are automatically adjusted along with the longest display width, dynamic adaptation is realized, development time cost generated by adjusting the display widths is reduced, the technical effect of improving the efficiency of right alignment display of the texts is realized, and the technical problem of low efficiency of right alignment display of the texts caused by manually realizing the right alignment of the texts due to the fact that the text widths need to be manually calculated repeatedly is solved.
Example 2
The technical solutions of the embodiments of the present invention will be illustrated below with reference to preferred embodiments.
In the Android user interaction process design, multiple entry entries are usually required, but the widths of prompt texts (consignees/mobile phone numbers) corresponding to input boxes may be different, as shown in fig. 2, where fig. 2 is a schematic diagram of text display according to one of the related arts, and since the text widths of the prompt texts (consignees/mobile phone numbers) are different, the display of texts to be input corresponding to the prompt texts on the right side is also uneven, resulting in poor use experience.
In order to solve the problem, all the prompt texts can be displayed in a right alignment mode, so that the prompt texts are aligned with the central axes of the corresponding texts to be input, and the prompt texts are expanded towards two sides.
Optionally, in order to implement the method, all texts may be filled in the multiple input boxes respectively, the display width of the text in each input box is manually set to be the longest display width according to the display width of the text with the longest display width, and then the right alignment of the displayed text is manually set.
In order to solve the above problem, the method for right alignment of text batches implemented by this embodiment may be: collecting all character strings of the text required for alignment through a character string set; traversing each character string, calculating the display width of each character string, and obtaining the maximum display width in the character string set; calculating the target number of continuous spaces "\ u00A 0" to be filled in the left side of each non-longest character string according to the width difference between the display width and the maximum display width of the character string, and sequentially filling the target number in the left side of the character string in a cyclic manner; returning the result in the form of Map, taking the original character string as Key, taking the spliced character string as Value, calling directly through the Key-Value correspondence when in use, and then displaying in text function controls such as TextView, so as to realize the effect of right alignment, as shown in fig. 3, where fig. 3 is a schematic diagram of right alignment display of a text according to an embodiment of the present invention. As shown in fig. 3, the text "me", "my detail page", where "me", "my detail" is a text with a non-longest display width, and "my detail page" is a text with a longest display width, and at least one space is added to the left side of "me", "my detail" and "my detail", and no space is added to the left side of "my detail page", so as to achieve the purpose of right-and-left aligned display in TextView text batch formatting, thereby improving the user experience.
The embodiment achieves the purpose of simplifying the right-justified display of the texts in the text function controls through the method, and the purpose of performing batch right alignment display on the texts in the text function controls is realized, the phenomenon that when the display width of the text with the longest display width is changed is avoided, the display width of other texts can not be changed in time, so that the longest display width can be dynamically acquired, and the display widths of other texts are measured in real time, so that the display widths of other displayed texts are automatically adjusted along with the longest display width, dynamic adaptation is realized, development time cost caused by adjustment of the display widths is reduced, and the technical effect of improving the efficiency of right-aligned display of the texts is realized, and the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated is solved.
Example 2
The embodiment of the invention also provides a device for processing the right alignment of the text. It should be noted that the processing apparatus for right alignment of text of this embodiment may be used to execute the processing method for right alignment of text of the embodiment of the present invention.
Fig. 4 is a schematic diagram of a device for right-justified processing of text, according to an embodiment of the present invention. As shown in fig. 2, the processing means 40 for right alignment of the text may comprise: a first acquisition unit 41, a second acquisition unit 42, a third acquisition unit 43, and a display unit 44.
A first obtaining unit 41, configured to obtain a plurality of original texts from a plurality of text function controls, wherein each text function control is used for inputting and displaying each original text.
And a second obtaining unit 42, configured to obtain an original character string corresponding to each original text, so as to obtain a plurality of original character strings.
A third obtaining unit 43, configured to obtain a plurality of target character strings corresponding to a plurality of original character strings, where the plurality of original character strings correspond to the plurality of target character strings one-to-one, and a left side of at least one first character string in the plurality of target character strings includes at least one space, so that a display width of each target character string is the same.
And the display unit 44 is used for displaying the corresponding target text in a right alignment mode in each text function control based on the display width of each corresponding target character string.
Optionally, the apparatus further comprises: the conversion unit is used for converting each original text into a corresponding character string to obtain a plurality of original character strings before obtaining the original character string corresponding to each original text to obtain the plurality of original character strings; acquiring a second character string with the longest display width from the plurality of original character strings; an adding unit, configured to add at least one continuous blank space to the left side of each third character string based on the display width of the second character string to adjust the display width of each third character string, where each third character string is a character string of the plurality of original character strings except the second character string, and the adjusted display width of each third character string is the same as the display width of the second character string; and the first determining unit is used for determining each adjusted third character string as a target character string corresponding to each third character string, wherein the target character string corresponding to the second character string is still the second character string.
Optionally, the adding unit includes: the first acquisition module is used for acquiring the width difference between the display width of the second character string and the display width of each third character string; and the first adding module is used for adding at least one continuous blank space to the left side of each third character string based on the width difference.
Optionally, the first adding module includes: a determination submodule for determining a target number of consecutive at least one space based on the width difference; and the adding submodule is used for adding a target number of blank spaces to the left side of each third character string.
Optionally, the adding submodule is configured to add a target number of spaces to the left of each third string by: an adding step of adding a space to the left side of each third character string; and the first judgment module is used for executing the first judgment step, judging whether the number of the added spaces on the left side of each third character string reaches the target number, if not, returning to the adding step, and if so, ending the adding step.
Optionally, the adding unit includes: the second adding module is used for adding a space to the left side of each third character string; and the second judging module is used for executing the second judging step, judging whether the display width of the third character string after the blank space is added reaches the display width of the second character string, if not, returning to the adding step, and if so, ending the adding step.
Optionally, the apparatus further comprises: a second determination unit configured to take each third character string as a target key; a third determination unit configured to take a target character string corresponding to each third character string as a target value; storing the target key and the target value through a key-value pair; the third acquisition unit 43 includes: a second obtaining module for obtaining a plurality of target character strings corresponding to the plurality of original character strings based on the key-value pairs.
Optionally, each original text of the embodiment is a prompt text for prompting a text to be input, and the text to be input corresponding to each prompt text is displayed in left alignment.
The embodiment acquires a plurality of original texts from a plurality of text function controls through a first acquiring unit 41, wherein each text function control is used for inputting and displaying each original text; acquiring an original character string corresponding to each original text through a second acquiring unit 42 to obtain a plurality of original character strings; acquiring, by the third acquiring unit 43, a plurality of target character strings corresponding to a plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one to one, and a left side of at least one first character string of the plurality of target character strings includes at least one space so that a display width of each target character string is the same; and displaying the corresponding target text in each text function control in a right alignment based on the display width of each corresponding target character string through the display unit 44. That is to say, the invention determines the original character string corresponding to each original text in each text function control, then obtains the target character string according to the corresponding relationship between the original character string and the target character string, the target character string corresponding to each original character string can achieve the purpose that the display width of each target character string is the same by adding a space to the left side of the original character string, and further displays the corresponding target text in right alignment based on the display width of each corresponding target character string, thereby achieving the purpose of simplifying the right alignment display of the texts in a plurality of text function controls, and achieving the purpose of performing batch right alignment display of the texts in a plurality of text function controls, even when the display width of the text with the longest display width is changed, the display widths of other texts can automatically change along with the display width in time, therefore, the technical effect of improving the efficiency of right alignment display of the text is achieved, and the technical problem of low efficiency of right alignment display of the text caused by manually realizing the right alignment of the text due to the fact that the width of the text needs to be manually and repeatedly calculated is solved.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (11)

1. A method for processing right alignment of text, comprising:
acquiring a plurality of original texts from a plurality of text function controls, wherein each text function control is used for inputting and displaying each original text;
acquiring an original character string corresponding to each original text to obtain a plurality of original character strings;
acquiring a plurality of target character strings corresponding to the plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings in a one-to-one manner, and the left side of at least one first character string in the plurality of target character strings comprises the at least one space, so that the display width of each target character string is the same;
and in each text function control, displaying corresponding target texts in a right alignment mode based on the display width of each corresponding target character string.
2. The method of claim 1, wherein prior to obtaining a plurality of target strings corresponding to the plurality of original strings, the method further comprises:
acquiring a second character string with the longest display width from the plurality of original character strings;
adding continuous at least one space to the left side of each third character string based on the display width of the second character string to adjust the display width of each third character string, wherein each third character string is a character string except the second character string in the plurality of original character strings, and the adjusted display width of each third character string is the same as the display width of the second character string;
and determining each adjusted third character string as the target character string corresponding to each third character string, wherein the target character string corresponding to the second character string is still the second character string.
3. The method of claim 2, wherein adding a continuous at least one space to the left of each of the third strings based on the display width of the second string comprises:
acquiring a width difference between the display width of the second character string and the display width of each third character string;
adding the continuous at least one space to the left of each of the third strings based on the width difference.
4. The method of claim 3, wherein adding the consecutive at least one space to the left of each of the third strings based on the width difference comprises:
determining a target number of consecutive said at least one space based on said difference in width;
adding the target number of spaces to the left of each of the third strings.
5. The method of claim 4, wherein adding the target number of spaces to the left of each of the third strings comprises:
adding a space to the left side of each third character string;
and a first judgment step of judging whether the number of the added spaces on the left side of each third character string reaches the target number, if not, returning to the adding step, and if so, ending the step.
6. The method of claim 2, wherein adding a continuous at least one space to the left of each third string based on the display width of the second string comprises:
adding a space to the left side of each third character string;
and a second judgment step of judging whether the display width of the third character string after the space is added reaches the display width of the second character string, if not, returning to the addition step, and if so, ending the process.
7. The method according to any one of claims 2 to 6,
the method further comprises the following steps: taking each third character string as a target key; taking the target character string corresponding to each third character string as a target value; storing the target key and the target value by a key-value pair;
acquiring a plurality of target character strings corresponding to the plurality of original character strings includes: obtaining the plurality of target character strings corresponding to the plurality of original character strings based on the key-value pairs.
8. The method according to any one of claims 1 to 6, wherein each original text is a prompt text for prompting a text to be input, and the text to be input corresponding to each prompt text is displayed in left alignment.
9. An apparatus for right-justified processing of text, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a display unit, wherein the first acquisition unit is used for acquiring a plurality of original texts from a plurality of text function controls, and each text function control is used for inputting and displaying each original text;
the second acquiring unit is used for acquiring the original character string corresponding to each original text to obtain a plurality of original character strings;
a third obtaining unit configured to obtain a plurality of target character strings corresponding to the plurality of original character strings, wherein the plurality of original character strings correspond to the plurality of target character strings one-to-one, and a left side of at least one first character string in the plurality of target character strings includes the at least one space, so that a display width of each of the target character strings is the same;
and the display unit is used for displaying the corresponding target text in a right alignment mode in each text function control based on the display width of each corresponding target character string.
10. A storage medium comprising a stored program, wherein the program, when executed, controls an apparatus on which the storage medium is located to perform a method of right-side alignment of text according to any one of claims 1 to 8.
11. A processor, characterized in that the processor is configured to run a program, wherein the program is configured to execute a method of right-justified processing of a text according to any one of claims 1 to 8 when running.
CN201911360788.6A 2019-12-25 2019-12-25 Method and device for processing right alignment of text, storage medium and processor Pending CN111126011A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911360788.6A CN111126011A (en) 2019-12-25 2019-12-25 Method and device for processing right alignment of text, storage medium and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911360788.6A CN111126011A (en) 2019-12-25 2019-12-25 Method and device for processing right alignment of text, storage medium and processor

Publications (1)

Publication Number Publication Date
CN111126011A true CN111126011A (en) 2020-05-08

Family

ID=70502489

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911360788.6A Pending CN111126011A (en) 2019-12-25 2019-12-25 Method and device for processing right alignment of text, storage medium and processor

Country Status (1)

Country Link
CN (1) CN111126011A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05346947A (en) * 1992-06-15 1993-12-27 Mutoh Ind Ltd Method and device for character string processing
US5835921A (en) * 1990-03-29 1998-11-10 Canon Kabushiki Kaisha Data processing apparatus for creating and storing a text file from input data
CN108108220A (en) * 2018-01-02 2018-06-01 武汉斗鱼网络科技有限公司 Character string animation effect implementation method and device based on text control
CN108710601A (en) * 2018-05-14 2018-10-26 广州腾讯科技有限公司 A kind of text display method and its equipment, storage medium, electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5835921A (en) * 1990-03-29 1998-11-10 Canon Kabushiki Kaisha Data processing apparatus for creating and storing a text file from input data
JPH05346947A (en) * 1992-06-15 1993-12-27 Mutoh Ind Ltd Method and device for character string processing
CN108108220A (en) * 2018-01-02 2018-06-01 武汉斗鱼网络科技有限公司 Character string animation effect implementation method and device based on text control
CN108710601A (en) * 2018-05-14 2018-10-26 广州腾讯科技有限公司 A kind of text display method and its equipment, storage medium, electronic equipment

Similar Documents

Publication Publication Date Title
CN108803967B (en) Chat window display method and device and electronic equipment
US20200043090A1 (en) Contract generation method and apparatus, server and storage medium
CN105975576B (en) Terminal content adaptive display method and device and terminal
CN105094775B (en) Webpage generation method and device
US9117314B2 (en) Information output apparatus, method, and recording medium for displaying information on a video display
CN105549936B (en) Data table display method and device
CN105701165B (en) Browser model switching method and switching device
JP2010282365A (en) Device for editing layout, and control method and program for the same
CN110705243A (en) Web page table setting method, device, equipment and computer storage medium
US20120242706A1 (en) Mobile terminal and method for adjusting menu bar softkey display dynamically
CN104391896A (en) Plane printed product typesetting method and system based on webpage
CN106022010A (en) File display method and device
CN111932198B (en) File auditing method and related products
CN111126011A (en) Method and device for processing right alignment of text, storage medium and processor
CN103605640B (en) Form adaption method and device
CN106484702B (en) Target web page access volume display method and device
CN110795654A (en) Webpage data display method and device, computer equipment and storage medium
CN111144063A (en) Processing method and device for aligning two ends of text, storage medium and processor
EP3385872B1 (en) Anti-counterfeiting method, device, storage medium and apparatus based on invalid map data
CN103309878B (en) Method and device used for layout in webpage displaying
CN106502496B (en) Window switching method and device
CN112464618A (en) Method and device for paging document data, storage medium and electronic equipment
CN104751058B (en) A kind of file scanning method and electronic equipment
CN113687889A (en) List page display method and system, computer program product and storage medium
CN102663137B (en) A kind of method and system being applied in mobile terminal show webpage

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