473,563 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List text files showing LFs and expanded tabs (was: Colorize expanded tabs)

Hi all,
in a previous post I asked help for colorizing expanded tab.
I wanted to list text files showing in colors LFs and the expanded
tabs.
I hoped to use only bash but, being impossible, I reverted to Python.
I programmed a very short script .
Here it is (... and I ask comments or critics):

# for Linux users
# starting from a list of all the lines of a text files (lFileList)

nNP=9 # n. of Not Printables characters
for line in lFileList:
nTab= line.count('\t' )
if nTab > 0:
for i in range(nTab):
nPosTab=line.fi nd('\t')
line=line.repla ce('\t',"\033[41m"+\
(8-(nPosTab-(nNP*i))%8)*' '+"\033[0m",1)
print line.replace('\ n',"\033[7m \033[0m\n"),
print

The Linux users can also use piping.
For example:
python lft.py lft.py|grep range

correctly displays:
for i in range(nTab):
+ the mark of the LF (a small white rectangle)

Bye.

Dec 12 '05 #1
2 1396

qwweeeit wrote:
Hi all,
in a previous post I asked help for colorizing expanded tab.
I wanted to list text files showing in colors LFs and the expanded
tabs.
I hoped to use only bash but, being impossible, I reverted to Python.
I programmed a very short script .
Here it is (... and I ask comments or critics):

# for Linux users
# starting from a list of all the lines of a text files (lFileList)

nNP=9 # n. of Not Printables characters
for line in lFileList:
nTab= line.count('\t' )
if nTab > 0:
for i in range(nTab):
nPosTab=line.fi nd('\t')
line=line.repla ce('\t',"\033[41m"+\
(8-(nPosTab-(nNP*i))%8)*' '+"\033[0m",1)
print line.replace('\ n',"\033[7m \033[0m\n"),
print

The Linux users can also use piping.
For example:
python lft.py lft.py|grep range

correctly displays:
for i in range(nTab):
+ the mark of the LF (a small white rectangle)

Bye.


?? Whatever editor you use for python should do this: (vim, komodo,
textmate)show and convert hard tabs to soft, show CR-LF, etc.

Dec 12 '05 #2
Hi Gene,
thank you for your reply, also if my post was meant to be only
an exercise to apply color to lfs and expanded tabs in listing
files and not to apply it to an editor.
However your comment has directed me to consider more
deeply other editors (I use kwrite).
I am inclined to change to vim but I haven't found the
vim module for python.
By the way I'm not sure that vim can display lfs and expanded
tabs in color!
Bye.

Dec 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3717
by: Daniel Hill | last post by:
OK, I have very, VERY basic background knowledge of VB6 and have now upgraded to VB.NET and now I'm struggling to bring up the forms I want. What I am looking to do is to have a click a command button bring up a form, and to have which form is brought up determined by which item is selected in the accompanying combo box. I've gathered...
6
16052
by: Haines Brown | last post by:
I find that when I use list-style-image with galeon or mozilla, padding is inserted between the symbol image and the following list text, while under IE 5.0 it seems to be inserted before the image instead of after it. li.up { list-style-image: url(../bin/arrow.png); height: 1.4em; margin-left: -0.4em; }
1
6343
by: relaxedrob | last post by:
Hi All, I want to write a select control and use a Javascript function to handle all click events on the control. Under certain circumstances I also wish to prevent the dropdown's list from being rendered. Here is a sample showing what I am _unsuccessfully_ trying to do. :-/ <html> <head>
5
2585
by: Rolan | last post by:
I have tried many iterations of constructing an expanded string link criteria for a list box selection, but have not been successful. The List Box uses a Totals Select Query that has a CustID, Customer Name, Invoice Date and Invoice Amount. There is no InvoiceID/number, otherwise it would be easy to resolve. Currently, I must use a...
2
1530
by: qwweeeit | last post by:
Hi all, from a string embedding tabs I want to colorize them when expanded: # Starting from a string: a= '1234\t5678\t\t90\nqwerty\nasdfg' # which embeds both tabs and lfs # printing it you obtain: print a # 1234 5678 90
35
3558
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is to management theses :-((( I must to declare and use all variable with this scheme :
1
4142
by: Little | last post by:
Could someone help me figure out how to put my project together. I can't get my mind wrapped around the creation of the 4 double Linked Lists. Thank your for your insight. 1. Create 4 double linked lists as follows: (a) A double linked list called NAMES which will contain all C like identifiers of less than 256 characters long...
8
11255
by: John | last post by:
Hi I need a auto-number field but with a letter prefix like "P1", "P2" etc. What is the way to achieve this? Is it possible to do this at table level? Thanks Regards
8
718
by: dmp | last post by:
What are Linked list? Please somebody show some ready made programs of linked list
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.