如何从一些文本输入获取文本缩进(制表符)? [英] How to get text indent (tabs) from some text input?

查看:918
本文介绍了如何从一些文本输入获取文本缩进(制表符)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,假设我正在编辑以下文本(\t是制表符,它不是文本)
'\t\t\tSome text ...'
和我输入键盘位置在S之前(没有选择的文本)
,我想获得'S'之前的分页数(在这种情况下为3)

For example, suppose I'm editing following text (\t is for tabs, it's not text) '\t\t\tSome text...' and my input keyboard position is right before 'S' (there is no selected text) and I want to get number of tabs before 'S' (in this case it's 3)

那么如何使用Win32 API获取这些数量的标签页?

So how to get that number of tabs using Win32 API?

ps
可能有一些函数获取整个当前行(然后解析该文本)?

p.s. Maybe some function to get whole current line (and then parse that text)?

编辑:
所以我想要我的程序

edit: So I want my program (that is running in background and does not have a GUI) to determine number of tabs from current active line in any text editor that is currently active (that I'm editing in).

推荐答案

对于一些应用程序,如标准的Windows记事本,可以从另一个应用程序做到这一点。记事本本身只是大的 Win32编辑控件在一个可调整大小的窗口内,因此所有常规的Win32编辑控制消息可以用于获取实际文本和插入位置等。

For some applications such as the standard Windows Notepad, it may be possible to do this from another application. Notepad itself is little more than big Win32 "Edit" control inside a resizeable window, so all the regular Win32 Edit control messages can be used to get the actual text and the caret position and so on.

一般情况下任何Windows文本编辑器,没有要求应用程序使用Win32编辑控件的文本编辑需求(事实上,这样做只是重新发明记事本)。没有标准的Win32 API方法来找出插入点所指向的位置,因为应用程序可以以任何适合的方式在屏幕上绘制文本(并且将在应用程序内部存储该文本,而没有相应的API)呼叫)。

However, in the general case of any Windows text editor, there is no requirement for applications to use a Win32 Edit control for their text editing needs (and in fact, to do so would be just reinventing Notepad). There is no standard Win32 API method to find out where the caret is pointing, because the application is free to draw text on the screen in any way it sees fit (and will store that text internally inside the application with no corresponding API for you to call).

这篇关于如何从一些文本输入获取文本缩进(制表符)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆