Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet65/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   61   62   63   64   65   66   67   68   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

#
command where 
#
is a number, as in 
esc
+

ctrl
+
d
. This will perform 
ctrl
+
d
(delete character) 5 times in a row. You can also per-
form the previous operation any number of times by doing 
ctrl
+
x
followed by z for each 
repetition. For instance, if you do 
ctrl
+
v
to move the cursor forward one screen’s worth, 
followed by 
ctrl
+
x zzz
, the 
ctrl
+
v
is executed 3 additional times to move the cur-
sor forward by three more screens (four total). You can also program emacs to repeat a 
sequence of keystrokes. This is known as a 
macro
. We briefly discuss recording and using 
a macro at the end of this section.
A buffer is merely a reserved area of memory for storing information. In emacs, you can 
have numerous open buffers. Using buffers, you can not only edit multiple documents at 
a time but you can also cut or copy and paste between them. You can even open multiple 
views into the same file by keeping each view in a separate buffer. Another interesting use 
of buffers is to have one buffer be a run-time environment, for instance, for the language 


Linux Applications

167
Common Lisp, and another buffer be a program that you are editing. You can then copy 
the program code from the second buffer into the first buffer to have it executed.
One special buffer is called the mini-buffer. This buffer appears in response to certain com-
mands. The mini-buffer is a single line in size that is used to input information into emacs 
such as a command or a file name. One operation that calls for the mini-buffer is the search 
command. The command 
ctrl
+
s
opens the mini-buffer (which is at the bottom of the emacs 
window). You enter your search term and press enter. The cursor is moved to the next instance 
of the search term. Note that search is not case sensitive. Continuing to press 
ctrl
+
s
searches 
for the next instance of the search term last entered. Entering any other key (such as new char-
acters to insert or new commands) causes the search term to be removed from the mini-buffer 
so that the next 
ctrl
+
s
causes the mini-buffer to ask for a new search term. The command 
ctrl
+
r
is a reverse search that again requests a search term in the mini-buffer.
The mini-buffer is also used with file operations. All file operations start with a 
ctrl
+
x
followed by another control operation. These are shown below.
• 
ctrl
+
x ctrl
+
w
—request new file name in mini-buffer, and save the file under this 
name.
• 
ctrl
+
x ctrl
+
s
—save the document under the current name, and prompt for file-
name if the buffer has not yet been saved and is unnamed.
• 
ctrl
+
x ctrl
+
f
—request file name in mini-buffer, and open that file in the main 
buffer.
• 
ctrl
+
x ctrl
+
c
—exit emacs, if the file has not been saved since recent changes, 
you will be asked if you want to save it; if the file has never been saved, emacs exits 
without saving!
Note that entering a file name in the mini-buffer can use tab completion to complete the 
directory and file names.
If you have multiple buffers open, the buffer name will appear at the bottom of the window 
immediately above the mini-buffer. To move between buffers, use 
ctrl
+
x ctrl
+<
left 
arrow
>
and 
ctrl
+
x ctrl
+<
right arrow
>
. Or, to move to a named buffer, use 
ctrl
+

b
. The mini-buffer will prompt you for a name. If the buffer name you provide is not one 
of the open buffers, you are given a new buffer of that name. To list all buffers, use 
ctrl
+

ctrl
+
b
. To remove the buffer you are currently in, use 
ctrl
+
x k
.
You can also open multiple buffers in the current window. The most common way to do 
this is to split the current buffer’s screen into half. This is done through 
ctrl
+
x 2
. With 
two buffers open, you can switch between them using 
ctrl
+
x o
. You can continue to 
divide buffers by doing 
ctrl
+
x
2 although after a while, you will find that your buffers are 
very small. You can also collapse from two buffers to one using 
ctrl
+
x 1
. See Figure 5.4 
for an example of emacs with two main buffers and a mini-buffer.
Let us see how we might use two buffers. You start emacs and open the file file1.txt. You 
wish to copy contents of file1.txt into file2.txt. Using 
ctrl
+
s
, you search forward for the 
beginning of the content that you wish to copy. Now, you do 
ctrl
+
x 2
to split the screen. 


168

Linux with Operating System Concepts
Use 
ctrl
+
x o
to move to the other buffer in the lower half of the screen. Here, you use 
ctrl
+
x ctrl
+
f
to open file2.txt. Move the cursor to the proper position in this file to 
insert. Do ctrl
+
x o to move back to the top buffer holding file1.txt. Using 
ctrl
+<
space
>
and 
esc
+
w
, you mark a region and copy it into a buffer. Again, you type 
ctrl
+
x o
to 
move to the lower buffer. Now, you use 
ctrl
+
y
to yank the copied content into place in 
the second file. You save this file (
ctrl
+
x ctrl
+
s
) and then kill this buffer using 
ctrl
+

k
. You are back to file1.txt in one buffer.
The mini-buffer is available whenever you issue the command esc
+
x. This allows you to 
enter a command in the mini-buffer. There are numerous commands available. A few are 
listed in Table 5.1 below. Tab completion is available to help you complete the name of a 
command. Or, if you want to see the commands available, press the tab key. This will list 
all commands. If you want to see just those that start with the letter ‘a’, type an ‘a’ in the 
mini-buffer followed by tab.
The doctor command runs a program called doctor. This is a variation of an older 
artificial intelligence program called Eliza. Give it a try, you might find it intriguing! The 
shell command opens a Linux shell inside the emacs buffer so that you can issue Linux 
Buffer 1
Buffer 2
Mini-buffer
FIGURE 5.4 
emacs with three buffers.
TABLE 5.1 
Some emacs Commands
append-to-file
check-parens
goto-line
auto-save-mode
copy-file
insert-file
calendar
count-lines-page
save-buffer
capitalize-region
count-lines-region
shell
capitalize-word
doctor
undo


Linux Applications

169
commands and capture all their outputs from within the text editor. In this way, you can 
literally save a session to a file for later examination (or reuse).
We wrap up our examination of emacs by considering macro definition and execution. 
A macro is essentially a recording of a series of keystrokes that you want to repeat many 
times. The keystrokes can comprise commands (e.g., 
ctrl
+
f

esc
+
b
), characters that 
are being entered into the document, and characters or commands being entered into the 
mini-buffer. This allows you to perform some complex editing task and then have emacs 
repeat it for you. To define a macro, you type 
ctrl
+
x ( 
. At this point, everything you 
enter is recorded. Recording stops when you type 
ctrl
+
x ) 
. With a macro defined, you 
can execute it using 
ctrl
+
x e
. Or, if you want to execute the macro repeatedly, you can 
use 
esc
+
#
(where # is a number) followed by 
ctrl
+
x e
.
Let us consider an example. You are editing a C program. The C program consists of a 
number of functions. Every function has the following format:
type name(type param, type param, type params, . . .)
{
instruction;
instruction;
. . .
}
You want to convert from C to pseudocode. You will do this by rearranging the code to 
look like this instead:
name type param, type param, type param, . . .
instruction;
instruction;
. . .
return type;
This requires that you
1. Cut the 
type
from the beginning of each function
2. Move the 
type
to the end of the function and add it to the word 
return
in the form 
return 
type
3. Remove the parens from the parameter list
4. Remove the 
{}
We will assume the cursor is currently at the beginning of the first function. To define 
this macro, do the following:
• 
ctrl
+
x (
—start defining the macro
• 
esc
+
d
—delete the first word (the type)


170

Linux with Operating System Concepts
• 
ctrl
+
a ctrl
+
d
—delete the blank space vacated by the type
• 
esc
+
f ctrl
+
d [space]
—move passed the name of the function to the open 
paren and delete it and then add a blank space to separate the function name from 
the first parameter
• 
ctrl
+
e ctrl
+
b ctrl
+
d
—move to the end of this line, back up, and delete the 
close paren
• 
ctrl
+
a ctrl
+
n ctrl
+
d ctrl
+
d
—move to the beginning of the next line and 
delete the open curly brace; a second deletion deletes the end of the line character so 
that the first instruction now appears on the second line
• 
ctrl
+
s }
—search for close curly bracket
• 
ctrl
+
a [space] [space] [space] [space] [space] return 
ctrl
+
y; ctrl
+
k
—move to the beginning of the line with the close curly bracket, 
add several spaces (or use 
<
tab
>
), insert the word 
return
followed by yanking 
back the cut item from the second step (this is the type, note that since we did not 
use another esc
+
d or a ctrl
+
k, this will still be in the yank buffer), and finally delete 
the close curly brace
• 
ctrl
+
s ( ctrl
+
a
—search forward for the next function that will be denoted by a 
parameter list with an open paren and move to the beginning of this line
• 
ctrl
+
x )
—end the macro
Now, we can repeatedly execute it using 
ctrl
+
x e
.
While this example may seem confusing, you can see the power of a macro. Once 
defined, this sequence of operations can be performed over and over to alter the format and 
the text within a document. Like vi, to understand and master emacs, you need to use it.
5.2.3 gedit
vi opens in the terminal window it was launched from, filling the window. emacs when 
launched from a terminal window will either open a new window in the GUI if this is 
available, or will fill the terminal window if you are restricted to a text-only environment. 
A third choice for a text editor is 
gedit
. This program 
only
runs in the GUI and so is not 
a choice if you have logged in through a text-only interface. However, you might find gedit 
far easier to use than either vi or emacs because you do not have to memorize any editing 
keystrokes. In spite of gedit’s availability, you should learn vi and/or emacs for the occa-
sions when you are operating in Linux without the GUI.
You can launch gedit from either the command line, typing 
gedit
, or selecting it 
from the Accessories submenu of the Applications menu. An open file in gedit is shown in 
Figure 5.5. The typical user would interact with gedit through the mouse to position the 
cursor and to select the menu items. However, as with most GUI software these days, hot 
key keystrokes are available to control operations such as 
ctrl
+
c
and 
ctrl
+
v
for copy 
and paste or 
ctrl
+
o
and 
ctrl
+
s
to open or save a file.


Linux Applications

171
5.3 PRODUCTIVITY SOFTWARE
Productivity software is a collection of software titles that enable the user to create docu-
ments whether they are word-processed documents, spreadsheets, presentation graphics 
documents, database relations, or graphic images. The most commonly used piece of 
productivity software is Microsoft Office. The open-source community has created both 
LibreOffice and OpenOffice as competitors. Both LibreOffice and OpenOffice have many 
of the same functions and features as Microsoft Office although they are not an exact 
match. When compared, LibreOffice is usually felt to have more features in common 
with Microsoft Office and is more powerful than OpenOffice. However, OpenOffice is 
able to import Microsoft Office files and export files to Microsoft Office format making it 
more flexible. Both LibreOffice and OpenOffice are open-source titles meaning that they 
are available in their source code format to allow for modifications. They are also both 
free. They are also available for most Linux platforms as well as Windows.
The titles of the individual software in LibreOffice and OpenOffice are the same. The word 
processor is called Writer, the presentation graphics program is called Impress, the spread-
sheet program is called Calc, the database management program is called Base, the draw-
ing software is called Draw, and there is a mathematical package called Math. Comparing 
LibreOffice or OpenOffice Writer to Microsoft Word, you find many of the same functions 
including wizards, tables, references and tables of content, spelling and grammar checkers, 
rulers, the ability to define macros, mail merge, footnotes/endnotes, headers, and footers.
Figure 5.6 displays the top portions of OpenOffice Writer, Impress, and Calc. Any user 
of Microsoft Office should have no difficulty learning the LibreOffice or OpenOffice equiv-
alents although both LibreOffice and OpenOffice are more like Microsoft Office 2003 than 
more recent versions as they use dropdown menus rather than menus of button bars, as 
you will notice in Figure 5.6.
FIGURE 5.5 
GUI-based gedit text editor.


172

Linux with Operating System Concepts
5.4 LATEX
Another popular software title often used by Linux users is called LaTeX. LaTeX is a word 
processor, but unlike Microsoft Word and OpenOffice Writer, it is not a WYSIWYG. Instead, 
in LaTeX, formatting commands are embedded within the text using special character 
sequences, somewhat like html. For instance, to denote that a sequence of characters should 
be underlined, you would use 
\underline{

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   61   62   63   64   65   66   67   68   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish