[go: up one dir, main page]

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
text
character string
strings
target
original
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

Landscapes

  • User Interface Of Digital Computer (AREA)

Abstract

本发明公开了一种文本的右对齐的处理方法、装置、存储介质和处理器。其中,该方法包括:在多个文本功能控件中获取多个原始文本,其中,每个文本功能控件用于输入并显示每个原始文本;获取每个原始文本对应的原始字符串,得到多个原始字符串;获取与多个原始字符串对应的多个目标字符串,其中,多个原始字符串与多个目标字符串一一对应,多个目标字符串中的至少一个第一字符串的左侧包括至少一个空格,以使每个目标字符串的显示宽度相同;在每个文本功能控件中,基于对应的每个目标字符串的显示宽度右对齐显示对应的目标文本。本发明解决了由于需要人工反复计算文本宽度,手动实现文本的右对齐所导致的文本的右对齐显示的效率低下的技术问题。

Figure 201911360788

The invention discloses a right-aligned text processing method, device, storage medium and processor. The method includes: acquiring multiple original texts from multiple text function controls, wherein each text function control is used to input and display each original text; acquiring an original string corresponding to each original text, and obtaining multiple Original strings; obtain multiple target strings corresponding to multiple original strings, wherein the multiple original strings are in one-to-one correspondence with multiple target strings, and at least one of the multiple target strings has a first string The left side includes at least one space, so that the display width of each target string is the same; in each text function control, the corresponding target text is displayed right-aligned based on the display width of each corresponding target string. The invention solves the technical problem of low efficiency of right-aligned display of text caused by the need to manually calculate the width of the text repeatedly and manually realize the right-alignment of the text.

Figure 201911360788

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.一种文本的右对齐的处理方法,其特征在于,包括:1. a processing method of the right alignment of text, is characterized in that, comprises: 在多个文本功能控件中获取多个原始文本,其中,每个所述文本功能控件用于输入并显示每个所述原始文本;Acquiring a plurality of original texts in a plurality of text function controls, wherein each of the text function controls is used to input and display each of the original texts; 获取每个所述原始文本对应的原始字符串,得到多个原始字符串;Obtain the original string corresponding to each of the original texts, and obtain a plurality of original strings; 获取与所述多个原始字符串对应的多个目标字符串,其中,所述多个原始字符串与所述多个目标字符串一一对应,所述多个目标字符串中的至少一个第一字符串的左侧包括所述至少一个空格,以使每个所述目标字符串的显示宽度相同;Acquire multiple target strings corresponding to the multiple original strings, wherein the multiple original strings are in one-to-one correspondence with the multiple target strings, and at least one of the multiple target strings is The left side of a character string includes the at least one space, so that the display width of each of the target character strings is the same; 在每个所述文本功能控件中,基于对应的每个所述目标字符串的显示宽度右对齐显示对应的目标文本。In each of the text function controls, the corresponding target text is displayed right-aligned based on the display width of each of the corresponding target character strings. 2.根据权利要求1所述的方法,其特征在于,在获取与所述多个原始字符串对应的多个目标字符串之前,所述方法还包括:2. The method according to claim 1, wherein before acquiring multiple target character strings corresponding to the multiple original character strings, the method further comprises: 从所述多个原始字符串中获取显示宽度最长的第二字符串;obtaining a second string with the longest display width from the plurality of original strings; 基于所述第二字符串的显示宽度向每个第三字符串的左侧添加连续的至少一个空格,以调整每个所述第三字符串的显示宽度,其中,每个所述第三字符串为所述多个原始字符串中除所述第二字符串之外的字符串,调整后的每个所述第三字符串的显示宽度与所述第二字符串的显示宽度相同;Add continuous at least one space to the left of each third character string based on the display width of the second character string to adjust the display width of each of the third character strings, wherein each of the third character strings The string is a character string other than the second character string among the plurality of original character strings, and the adjusted display width of each of the third character strings is the same as the display width of the second character string; 将调整后的每个所述第三字符串确定为与每个所述第三字符串对应的所述目标字符串,其中,与所述第二字符串对应的所述目标字符串仍为所述第二字符串。Each of the adjusted third character strings is determined as the target character string corresponding to each of the third character strings, wherein the target character string corresponding to the second character string is still the target character string corresponding to the second character string. the second string. 3.根据权利要求2所述的方法,其特征在于,基于所述第二字符串的显示宽度向每个所述第三字符串的左侧添加连续的至少一个空格包括:3. The method according to claim 2, wherein adding at least one continuous space to the left side of each of the third character strings based on the display width of the second character string comprises: 获取所述第二字符串的显示宽度与每个所述第三字符串的显示宽度之间的宽度差;obtaining the width difference between the display width of the second character string and the display width of each of the third character strings; 基于所述宽度差向每个所述第三字符串的左侧添加连续的所述至少一个空格。The at least one space in succession is added to the left side of each of the third character strings based on the width difference. 4.根据权利要求3所述的方法,其特征在于,基于所述宽度差向每个所述第三字符串的左侧添加连续的所述至少一个空格包括:4. The method of claim 3, wherein adding the continuous at least one space to the left of each of the third character strings based on the width difference comprises: 基于所述宽度差确定连续的所述至少一个空格的目标数量;determining a target number of consecutive said at least one space based on said width difference; 向每个所述第三字符串的左侧添加所述目标数量的空格。The target number of spaces is added to the left of each of the third strings. 5.根据权利要求4所述的方法,其特征在于,向每个所述第三字符串的左侧添加所述目标数量的空格包括:5. The method of claim 4, wherein adding the target number of spaces to the left of each of the third character strings comprises: 添加步骤,向每个所述第三字符串的左侧添加一个空格;adding the step of adding a space to the left of each of said third strings; 第一判断步骤,判断向每个所述第三字符串的左侧已添加的空格的数量是否达到所述目标数量,如果否,则返回所述添加步骤,如果是,则结束。The first judging step is to judge whether the number of spaces added to the left side of each of the third character strings reaches the target number, if not, return to the adding step, and if so, end. 6.根据权利要求2所述的方法,其特征在于,基于所述第二字符串的显示宽度向每个第三字符串的左侧添加连续的至少一个空格包括:6. The method according to claim 2, wherein 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 comprises: 添加步骤,向每个所述第三字符串的左侧添加一个空格;adding the step of adding a space to the left of each of said third strings; 第二判断步骤,判断添加所述空格后的所述第三字符串的显示宽度是否达到所述第二字符串的显示宽度,如果否,则返回所述添加步骤,如果是,则结束。The second judgment step is to judge whether the display width of the third character string after adding the space reaches the display width of the second character string, if not, return to the adding step, and if so, end. 7.根据权利要求2至6中任意一项所述的方法,其特征在于,7. The method according to any one of claims 2 to 6, characterized in that, 所述方法还包括:将每个所述第三字符串作为目标键;将与每个所述第三字符串对应的所述目标字符串作为目标值;将所述目标键和所述目标值通过键-值对进行存储;The method further includes: using each of the third character strings as a target key; using the target character string corresponding to each of the third character strings as a target value; using the target key and the target value Stored by key-value pairs; 获取与所述多个原始字符串对应的多个目标字符串包括:基于所述键-值对获取与所述多个原始字符串对应的所述多个目标字符串。Acquiring the multiple target strings corresponding to the multiple original strings includes: acquiring the multiple target strings corresponding to the multiple original strings based on the key-value pair. 8.根据权利要求1至6中任意一项所述的方法,其特征在于,每个所述原始文本为提示文本,用于提示待输入文本,与每个所述提示文本对应的所述待输入文本左对齐显示。8. The method according to any one of claims 1 to 6, wherein each of the original texts is a prompt text for prompting a text to be input, and the to-be-entered text corresponding to each prompt text Input text is displayed left-aligned. 9.一种文本的右对齐的处理装置,其特征在于,包括:9. A processing device for right alignment of text, characterized in that, comprising: 第一获取单元,用于在多个文本功能控件中获取多个原始文本,其中,每个所述文本功能控件用于输入并显示每个所述原始文本;a first obtaining unit, configured to obtain a plurality of original texts from a plurality of text function controls, wherein each of the text function controls is used to input and display each of the original texts; 第二获取单元,用于获取每个所述原始文本对应的原始字符串,得到多个原始字符串;The second obtaining unit is used to obtain the original string corresponding to each of the original texts, and obtain a plurality of original strings; 第三获取单元,用于获取与所述多个原始字符串对应的多个目标字符串,其中,所述多个原始字符串与所述多个目标字符串一一对应,所述多个目标字符串中的至少一个第一字符串的左侧包括所述至少一个空格,以使每个所述目标字符串的显示宽度相同;a third acquiring unit, configured to acquire multiple target character strings corresponding to the multiple original character strings, wherein the multiple original character strings are in one-to-one correspondence with the multiple target character strings, and the multiple target character strings are in one-to-one correspondence. The left side of at least one first character string in the character string includes the at least one space, so that the display width of each of the target character strings is the same; 显示单元,用于在每个所述文本功能控件中,基于对应的每个所述目标字符串的显示宽度右对齐显示对应的目标文本。The display unit is configured to right-align and display the corresponding target text in each of the text function controls based on the display width of each of the corresponding target character strings. 10.一种存储介质,其特征在于,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行权利要求1至8中任意一项所述的文本的右对齐的处理方法。10 . A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program is run, a device where the storage medium is located is controlled to execute the process of the text according to any one of claims 1 to 8 . Right-aligned processing method. 11.一种处理器,其特征在于,所述处理器用于运行程序,其中,所述程序运行时执行权利要求1至8中任意一项所述的文本的右对齐的处理方法。11 . A processor, characterized in that the processor is configured to run a program, wherein, when the program runs, the method for processing right-alignment of text according to any one of claims 1 to 8 is executed.
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
JP5219928B2 (en) Editing apparatus, editing method, and program
CN102662679B (en) Method and device for implementing personalized user interface
CN105099861A (en) User emotion-based display control method and display control device
CN111581565B (en) Page style configuration method, system, medium and equipment
CN106507200B (en) Video playing content insertion method and system
US20150178263A1 (en) System and Method for Constructing Markup Language Templates and Input Data Structure Specifications
CN104021219A (en) A method and device for generating a data template
CN107741935A (en) Data lead-in method and data importing device
CN105989069A (en) Webpage adaptive adjustment method and device
CN107330399A (en) Chinese character splitting method and device, computer storage medium and electronic equipment
CN116384356B (en) Method, device, equipment and medium for creating form row of OFD file
WO2025130199A1 (en) Question-answering model template answering method and apparatus
CN111126011A (en) Method and device for processing right alignment of text, storage medium and processor
CN105389308A (en) Display processing method and device for web pages
CN107766427A (en) A kind of page rendering method and system
CN107784064B (en) Webpage data processing method and device, computer equipment and computer storage medium
CN109657217A (en) Report-generating method, device and electronic equipment
CN111144063A (en) Method, device, storage medium and processor for processing justified text
CN103309878B (en) Method and device used for layout in webpage displaying
JP2018537750A (en) Method and system for associating speech and patterns with personalization
CN101963892B (en) Method and device for printing table data
TWI604319B (en) Web page information synchronous browsing system and browsing method thereof
CN112464618A (en) Method and device for paging document data, storage medium and electronic equipment
CN104572604B (en) Word subfield processing method and processing device
CN113687889A (en) List page display method and system, computer program product and storage medium

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200508