📄 pretty
字号:
#!/usr/bin/env perl# -*- perl -*-# Package : omniidl# pretty Created on: 2000/3/13# Author : David Scott (djs)## Copyright (C) 1999 AT&T Laboratories Cambridge## This file is part of omniidl.## omniidl is free software; you can redistribute it and/or modify it# under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, USA.## Description:## Simple perl script to reformat the C++ output for visual inspectionuse strict;my $indent = " " x 2;sub out{ my $text = shift; my $level = shift; print $indent x $level; print $text; print "\n";}my $last_line_blank = 0;my $this_line_blank = 0;my $level = 0;sub process{ my $text = shift; $_ = $text; # dont have runs of blank lines $this_line_blank = 0; if ($_ !~ /\S/){ $this_line_blank = 1; } next if ($this_line_blank and $last_line_blank); $last_line_blank = $this_line_blank; if ( (/\}/) or (/_CORBA_MODULE_END/) ){ $level --; } if (/\#/){ out($_, 0); }elsif (/\:$/){ out($_, $level - 1); }else{ out($_, $level); } if ( (/\{/) or (/_CORBA_MODULE_BEG/) ){ $level ++; }}my $preproc = 0;while (<>){ # strip of initial and leading whitespace if (/^\s*(.+)\s*$/){ $_ = $1; } if (/\{.*\}/){ out($_, $level); next; } my $line = $_; # consider inserting a blank line if ($line =~ (/\#/)){ if (!$preproc){ if (!$last_line_blank){ print "\n"; $last_line_blank = 1; } } $preproc = 1; }else{ $preproc = 0; } process($line); if ($line =~ (/\}\;$/)){ print "\n"; $last_line_blank = 1; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -